int to string
hkimball
Posts: 15
Quick question.
What am I doing wrong here?· When I pass in this negative number, convert to int then back to string i get 53,502.· If I pass in 12034 it comes back 12,304.· Am I missing something in my tostr funtion call?·
tempint := num.FromStr(STRING("-12034"),num#DEC)
tv.str(num.tostr(tempint,num#ddec))
Thanks in advance.
Harold
What am I doing wrong here?· When I pass in this negative number, convert to int then back to string i get 53,502.· If I pass in 12034 it comes back 12,304.· Am I missing something in my tostr funtion call?·
tempint := num.FromStr(STRING("-12034"),num#DEC)
tv.str(num.tostr(tempint,num#ddec))
Thanks in advance.
Harold
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
-12034
-12034
-12,034
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
i think i figured out what was causing the problem though, thanks to your example
in your example tempint is a long, in my code tempint was a word, when tempint is a word the results i stated are returned by the conversion
question??
if you are using signed integers, the variables passed to the numbers object must be longs???
i just tried it out and i can keep my variable a word as long as i sign-extend the value when i pass it into the tostr function
thanks for the tip