Page 1 of 1
Convert strings in numbers
Posted: Sat Aug 17, 2013 5:51 am
by Klaus_1963
In C# I use Double.Parse("1e-234") to convert a string to a (very small or big) number, or Convert.ToString(1e-234) to convert a small double to string (and the result shown is not only "0". It is 1e-234 as it should be).
What are the corresponding commands in PB, which works correctly? StrD and Val are not useable for small or big values...
Thanks, Klaus
Re: Convert strings in numbers
Posted: Sat Aug 17, 2013 7:54 am
by TI-994A
Klaus_1963 wrote:...Double.Parse("1e-234") to convert a string to a (very small or big) number, or Convert.ToString(1e-234) to convert a small double to string
Hello Klaus_1963. I believe that PureBasic's not able to handle such huge or small numbers.

Re: Convert strings in numbers
Posted: Sat Aug 17, 2013 8:48 am
by TassyJim
You might have problems displaying the result, but valD does work.
Code: Select all
firstvalueastring.s ="1e234"
firstvalue.d=ValD(firstvalueastring)
secondvalueastring.s ="1.5e230"
secondvalue.d=ValD(secondvalueastring)
result.d=firstvalue/secondvalue
Debug result
I don't think there is a command for displaying numbers in scientific notation (unfortunately)
Doing a search for scientific notation and I found this:
http://www.purebasic.fr/english/viewtop ... c+notation
Jim
Re: Convert strings in numbers
Posted: Sat Aug 17, 2013 10:55 am
by Klaus_1963
Thanks a lot
Unfortunately, it's not a solution for my problem.
@TassyJim: if you debug a large number e.g. 1e+68 and you like to check it with a debug output, its not possible. Only if you count the zeros
What a pity! Otherwise PB could be used for easy programming scientific applications...
Of course, there is code available to view very small numbers. But it would be much more elegant, if I can use e.g. StrD etc. to view the number in a label field, and the debug output to check the number quickly.
Every other pl I use know such a command with works correctly...
Would be great, if Fred implement this...
Klaus