deltatheta
Member
I'm not sure I understand what this all means.
So the function would take an int like 23, convert it to the string "23", convert that string "23" into the string "17" (23 is 17 in hexadecimal), and then convert that "17" into the int 17?
And this was bad/wrong because numbers are stored in binary so there was no real need to do all those conversions?
The underlying storage format in memory is a bit of a red herring. "0x17" and "23" and
"0b10111" and "027" and "XXIII" are all string representations of the same number. There's no reason to ever convert a decimal number to hex. You just take the number that you've got and display it as a hex number.
The function the students wrote took in (int) 23, converted it to (string) "23", converted that to string "17", then converted it back to (int) 23. The function literally didn't do anything.