I have to convert an entered number to decimal...how can I do this? won't the computer think the number is decimal when inputted?
Printable View
I have to convert an entered number to decimal...how can I do this? won't the computer think the number is decimal when inputted?
Where do you get the numbers from? Is it read from a file or does the user have to enter them manually?
If the user enters numbers manually, any conversion to the binary format, in which all values are stored in memory, is performed automatically.
In C++ you can enter (integral) numbers in three formats.
* decimal (base = 10)
* octal (base = 8, the first digit must be a zero)
* hexadecimal (base = 16, the first two digits must be 0x)
This is the same way if you enter a number in your code.
Floating point values can only be entered decimally, but I'm not sure about that.