Board index » delphi » number to string

number to string

I have come across a problem with converting a number to a string.

I am using Delphi 2.01 and the function str.

I tried str(mynumber,mystring)

and got it formatted as a numer with E etc.
So I tried str(mynumber:0:0,mystring) and got a proper string but with some odd results.

For example 123456789 converted to 123456792
and 23456789 became 23456788

Has anyone a way to turn a double into a proper string?

johan

 

Re:number to string


Quote
jo...@lindgren.pp.se wrote:
>I have come across a problem with converting a number to a string.
>I am using Delphi 2.01 and the function str.
>I tried str(mynumber,mystring)
>Has anyone a way to turn a double into a proper string?

Try FloatToStr and FloatToStrF.

=====================================================
Nothing is as terrible to see as ignorance in action.
[Goethe]
--
For my public PGP key, see my web page at
http://www.mindspring.com/~isoftdev/homeofmatt.html

Re:number to string


Quote
jo...@lindgren.pp.se wrote:

> I have come across a problem with converting a number to a string.

> I am using Delphi 2.01 and the function str.

> I tried str(mynumber,mystring)
> For example 123456789 converted to 123456792
> and 23456789 became 23456788

> Has anyone a way to turn a double into a proper string?

> johan

Try using MyString:=IntToStr(MyNumber)
and MyString:=FloatToStr(MyFloat)
and even FloatToStrFmt(MyFloat) and something

--
W.A. Veling             Dorpsweg 78
MediaLab                1697 KD Schellinkhout
www.medialab.nl             The Netherlands
http://www.medialab.nl/crew/annehome.htm

Other Threads