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
Convert strings in numbers
-
Klaus_1963
- User

- Posts: 29
- Joined: Wed Nov 25, 2009 9:37 am
Convert strings in numbers
PureBasic 4.72 LTS - Windows / MacOS / Linux / strong coffee / stronger coffee / Coffee intravenously...
Re: Convert strings in numbers
Hello Klaus_1963. I believe that PureBasic's not able to handle such huge or small numbers.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
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel 
Re: Convert strings in numbers
You might have problems displaying the result, but valD does work.
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
Code: Select all
firstvalueastring.s ="1e234"
firstvalue.d=ValD(firstvalueastring)
secondvalueastring.s ="1.5e230"
secondvalue.d=ValD(secondvalueastring)
result.d=firstvalue/secondvalue
Debug resultDoing a search for scientific notation and I found this:
http://www.purebasic.fr/english/viewtop ... c+notation
Jim
-
Klaus_1963
- User

- Posts: 29
- Joined: Wed Nov 25, 2009 9:37 am
Re: Convert strings in numbers
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
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
PureBasic 4.72 LTS - Windows / MacOS / Linux / strong coffee / stronger coffee / Coffee intravenously...

