Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / String to Real Number conversion?

Author
Message
turchino
21
Years of Service
User Offline
Joined: 11th Feb 2003
Location: Italy
Posted: 17th Feb 2003 02:05
Hello,
I read a string from a file with
read string fileno, a$

and the string is a$="Hello: -1.45"
then I extract the number using b$=right$(a$,5)

now how can I convert this string to a REAL number?
if I use a=val(b$) I get 1, which is an Integer...
How can I get a=-1.45 with DBPro??

Thank you...
Chiwawa
22
Years of Service
User Offline
Joined: 13th Oct 2002
Location: Canada
Posted: 17th Feb 2003 03:03
i dont have db pro...but Real in DB r declared with #..

it should be:
a#=val(b$)
turchino
21
Years of Service
User Offline
Joined: 11th Feb 2003
Location: Italy
Posted: 17th Feb 2003 09:48
Yes,also # is a real number in DBPro, but it doesn't accept it,because the command VAL returns an integer, it's written on help file...
MrTAToad
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 17th Feb 2003 14:53
I've got a plug-in for converting strings to floating point values.

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
turchino
21
Years of Service
User Offline
Joined: 11th Feb 2003
Location: Italy
Posted: 17th Feb 2003 18:03
I have resolved the problem,and I wrote this code.
I'm posting it, maybe it's usefull to someone...

Chiwawa
22
Years of Service
User Offline
Joined: 13th Oct 2002
Location: Canada
Posted: 17th Feb 2003 18:24
ok ...ez ..just take ur number in 2 part...ive made this code....it work fine...

Chiwawa
22
Years of Service
User Offline
Joined: 13th Oct 2002
Location: Canada
Posted: 17th Feb 2003 18:24
god ..i was writing mine during u post...
turchino
21
Years of Service
User Offline
Joined: 11th Feb 2003
Location: Italy
Posted: 17th Feb 2003 18:27
)

Chiwawa,we got the same result with two different codes!
Now the users have also a choice...

Thank you...
turchino
21
Years of Service
User Offline
Joined: 11th Feb 2003
Location: Italy
Posted: 17th Feb 2003 18:27
and you were writing mine during u post...
Chiwawa
22
Years of Service
User Offline
Joined: 13th Oct 2002
Location: Canada
Posted: 17th Feb 2003 18:32
hmm ive tested your ...and when u enter a string too long..it cut some part... ive tester 123456789.123456789

and i get 123456792 ..with your...and with mine i get 1.23457e+008=123457.000

then...mine work ..your not sorry im the king ..just kidding..
turchino
21
Years of Service
User Offline
Joined: 11th Feb 2003
Location: Italy
Posted: 17th Feb 2003 18:33
I'm not working for Nasa, so 5 digits after the . are enough for me!!
Chiwawa
22
Years of Service
User Offline
Joined: 13th Oct 2002
Location: Canada
Posted: 17th Feb 2003 18:35
doh... damn..why edit doesnt work!!!

i wrote 1.23457e+008=123457.000

but its 1.23457e+008=123457000.0
Chiwawa
22
Years of Service
User Offline
Joined: 13th Oct 2002
Location: Canada
Posted: 17th Feb 2003 18:37
...i was still writing a post..during u post..

yeah i know..5 digigt is enough..but.....if u give something like that....in a calcul...then ..your calcul is .......WRONG ...mip mip
Chiwawa
22
Years of Service
User Offline
Joined: 13th Oct 2002
Location: Canada
Posted: 17th Feb 2003 18:50
in function now :

Chiwawa
22
Years of Service
User Offline
Joined: 13th Oct 2002
Location: Canada
Posted: 18th Feb 2003 01:13
damn...i should test it before..to do that......it return an real..but i know in help..its wrote integer...but.

e.e.e maybe in DBPRo..but in DB 1.13..it return both..

Login to post a reply

Server time is: 2024-11-24 01:29:18
Your offset time is: 2024-11-24 01:29:18