How to convert a number to a float
Community Forums/General Help/How to convert a number to a float
| ||
Heres my dilemma, erm its not a number to start with it is numbers within a string that I have extracted the numbers from surrounding ascii chars. I have a number that is -0.3456789 When I attempt to convert it to a float for storing in an array (to eventually write to a file) the following fails to extract the number (just gets a zero):- vallong=Float(long$) I am suspecting that the Float type conversion is failing to detect the -ve in front ..... |
| ||
s$ = "0.44" d# = s$ Print d# Works in blitz3d. It's probably because your not setting vallong to a float via the #? |
| ||
Yeess, Ross C your the man! Incidentally its a lat or a long, now to do a little lat/long conversion to some cartesian co-ordinates, work out the difference between the max and the min & plot some co-ords accordingly on a map. |
| ||
Hmm, now I'm trying to store the signed float in an array, is this possible? If not then I'll simply need to store the -0.1234354657 to file as a string... But it'd be really handy to dim an array to hold a float. Not sure if possible though. Am loathe to make a protracted string manipulation but I might have to. |
| ||
You'd need to dim a # array:Dim array#(10) array(5) = 0.54 array(6) = 5 Print array(5) Print array(6) |
| ||
Thanks RossC, you are most definitely the man! |
| ||
All of those problems go away if you use SuperStrict. |
| ||
Blitz3D doesn't have SuperStrict. |
| ||
@big10p, good point - thanks anyway Taskmaster. |
| ||
Whoops, didn't realize it was Blitz3D. That'll teach me not to read signatures. :) |