# String representation of numbers

4 messages
Open this post in threaded view
|
Report Content as Inappropriate

## String representation of numbers

 Hi, I got stuck at the string representation of numbers, section 12.1.2. In the string2int method, what are we actually doing? Are we converting from decimal to binary? Or are we converting from characters to ASCII?  English is not my first language, so it is possible I translated something wrong as this is completely lost on me.
Open this post in threaded view
|
Report Content as Inappropriate

## Re: String representation of numbers

 Administrator int2String converts a 16-bit 2's-compliment integer to a String containing the ASCII characters for the base 10 representation of the integer. int2String(-123) should return a String with the characters '-', '1', '2', '3'. string2Int does the reverse, converting a String containing the base 10 representation of a number to a 16-bit 2's-compliment integer. --Mark
Open this post in threaded view
|
Report Content as Inappropriate

## Re: String representation of numbers

 Thank you! I think I might understand it now. So if I had int2string(99), I would convert the 9s into base 10 and then append it, where I would have to use the ASCII code for those numbers. And in case of the string2Int method, I would get a string, then find the ASCII code for each character, got the number in base 10 from it, convert it to binary and return. Would that be correct?