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.

DarkBASIC Professional Discussion / anyone knows how to make float out of string?

Author
Message
Wanja
21
Years of Service
User Offline
Joined: 28th Aug 2002
Location:
Posted: 26th Sep 2002 23:32
At first:
Return Float=VAL(String)
DOES NOT WORK for this


any suggestions? HEEEEEEEEEELPPPPP ME PLEASEEEEE
The One Ring
21
Years of Service
User Offline
Joined: 15th Sep 2002
Location: United States
Posted: 27th Sep 2002 05:45
I tried a few things as well, but the VAL function drops the decimal. I tried several ways...



However, the 0.6 is dropped off. It only prints "102" for me...

Interesting... anyone else see this??
MrTAToad
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 27th Sep 2002 12:07
According to the documentation, VAL only works with integers (for some strange reason)

Yes, I really am THAT good...
Zero
21
Years of Service
User Offline
Joined: 28th Aug 2002
Location: Finland
Posted: 27th Sep 2002 12:45
VAL used to work with floats in DB#1. I afraid my primary project is ruined now.. NO! I hope they'll fix this.. for example in version 1 (before the patch) make object cube/sphere/... didn't accept floats as size.. now after the patch they do!
I'm looking for a temportary solution now.. maybe I will write a DLL that returns double value from a string.

The evil plan is now even closer!
- - - - - - - - - - - - - - - - - - - -
Specs:- P3 550 Nvidia TNT2M64, 192Mb RAM
Shadow Robert
21
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 27th Sep 2002 14:53
you could do this...
however i'm not quite sure why you'd save a numberas a string :s
i'd just note the numbers and compile everything into a single file using the float command - might take a lil longer but makes sense.
string$="10602"
float#=Val(string)
float#=float#-100

i'd like someone to actually plz show me an example for string values

"For the Greater Good"...
Kyi'Aun (Jedi Master) Rai'Ka
djlaptop
21
Years of Service
User Offline
Joined: 21st Sep 2002
Location:
Posted: 28th Sep 2002 01:32
I have written a function that will do this for you. It's dependent upon two of my other functions that I will include here --- the function you're interested in is StringToFloat.

Let me know what you think!



Wanja
21
Years of Service
User Offline
Joined: 28th Aug 2002
Location:
Posted: 28th Sep 2002 02:26
Jesus!

djlaptop
21
Years of Service
User Offline
Joined: 21st Sep 2002
Location:
Posted: 28th Sep 2002 09:04
Yes, it's long. Yes, it's not all that fast.


But hey, it works.

Login to post a reply

Server time is: 2024-04-25 05:26:27
Your offset time is: 2024-04-25 05:26:27