how to represent negative number to array of integers ?
Posted
by stdnoit
on Stack Overflow
See other posts from Stack Overflow
or by stdnoit
Published on 2010-05-15T18:42:27Z
Indexed on
2010/05/15
18:44 UTC
Read the original article
Hit count: 185
java
I must convert string of 1324312321 to array of integers in java
this is fine. I could use integer parseint and string substring method
but how do I repesent -12312312 to my original array of integer..
the fact that - is a char / string and convert to array of integer would alter the value ( even though I convert - to integer-equivalent , it would change the rest of 12312312)
it must be an array of integers and how should I convert negative numbers and still keeep the same value
somehow reminding me of two complements trick but i dont think i need to go down to binary level in my program..
any other trick for doing this?
thanks!
© Stack Overflow or respective owner