|
For example: the value twelve is represented by 00000000000000000000000000001100
For example, to print 12 the computer must send these ASCII codes to the terminal: 00110001 00110010 |
Problem:
|
Again, there is a disconnect between internal (2's complement) representation of a number and what a terminal needs to receive to display the number
|
Therefore: we need to convert the input (2's complement) representation to the ASCII representation
You may not have use this method in CS170/CS171, because the conversion also take place in the println( ) method.
Here's an example how you can convert an int variable into a string:
int i = 123; String s; s = Integer.toString(i); // Convert i to String representation |
Again, in CS255, we will reveal the secret inside the toString( ) method so you will understand the computer operation better.
Also, unlike the Boolean example, the conversion from 2's complement representation of numbers to ASCII representation of numbers is more complex and will take more than 1 webpage to explain....