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.

Author
Message
richardneail
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 29th Nov 2003 22:55
Hi,

Can anyone tell me how you would convert a float value to a string ?

Rich

You might never win but if you give in will you ever know ??????
the_winch
23
Years of Service
User Offline
Joined: 1st Feb 2003
Location: Oxford, UK
Posted: 29th Nov 2003 23:07
string = str$(float)

dbpro : p166mmx @ 233 : 256mb : sb 128pci : sis onboard
richardneail
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 30th Nov 2003 18:52
Yes that will work but as you will see if you try it that it wont give you a correct result.

e.g. if the float is 1.1 then the result you get will not be 1.1 but somthing like 1.100112.

I have sorted the problem anyway but thanks for your help.

Note that the STR$ command actually says it can only accept integer numbers, I will ammend this in the help files.

Rich

You might never win but if you give in will you ever know ??????
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 30th Nov 2003 19:26
Actually, the number it is displaying is correct ... that's something else that you might like to mention in the help.

Sorry for the length of these links:

Floating point representation : http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/_core_ieee_floating.2d.point_representation_and_microsoft_languages.asp
Losing precision in floating point maths : http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/_core_why_floating_point_numbers_may_lose_precision.asp

Login to post a reply

Server time is: 2026-07-27 01:32:56
Your offset time is: 2026-07-27 01:32:56