Page 1 of 1
Posted: Fri Feb 22, 2002 12:52 pm
by BackupUser
Restored from previous forum. Originally posted by wongchunkit.
Dear All,
I'm writing something to display a floating point variable. However, Str() function only display the integer part. Does anybody kown how to fix this?
e.g.
x.f = 2.2225
MessageRequester("Information", "x = " + Str(x), 0)
Thanks!
A Registered Beginer on PureBasic,
Wong Chun Kit
Posted: Fri Feb 22, 2002 1:54 pm
by BackupUser
Restored from previous forum. Originally posted by Pupil.
Dear All,
I'm writing something to display a floating point variable. However, Str() function only display the integer part. Does anybody kown how to fix this?
e.g.
x.f = 2.2225
MessageRequester("Information", "x = " + Str(x), 0)
Thanks!
A Registered Beginer on PureBasic,
Wong Chun Kit
Hi!
Use this command to get desired result
string.s=StrF(variable.f, decimals.l)
Posted: Fri Feb 22, 2002 2:05 pm
by BackupUser
Restored from previous forum. Originally posted by wongchunkit.
Thanks Pupil,
It works now. However, please try the below code:
====== Begin ======
x.f = 1.0
y.f = 1.000001
For i = 1 To 100000000
x = x * y
Next i
MessageRequester("Information", "x = " + StrF(x,10), 0)
====== End ======
It show me x = 1.#INF
What does it mean?
A Registered Beginer on PureBasic,
Wong Chun Kit
Posted: Fri Feb 22, 2002 2:44 pm
by BackupUser
Restored from previous forum. Originally posted by MrVainSCL.
wongchunkit wrote:
It show me x = 1.#INF
What does it mean?
Hi wongchunkit
Mhhh.. i tested your codesnip and i was a bit wondered... because i get everytime "0" as result ;( I have tested with fullversion of PB2.90 Windows... As i know, the Float() stuff in PB is a bit buggy...!? Sorry, i cant help you ;(
PIII450, 256MB Ram, 6GB HD, RivaTNT, DirectX8.1, SB AWE64, Win98SE + Updates...
greetz
MrVainSCL! aka Thorsten
Edited by - MrVainSCL on 22 February 2002 14:45:30
Posted: Fri Feb 22, 2002 3:15 pm
by BackupUser
Restored from previous forum. Originally posted by Pupil.
It show me x = 1.#INF
What does it mean?
Don't know but probably means that you number overflowed i.e. the largest number that can be presented by the IEEE 754 floating-point representation is in the neighborhood of 1.0*10^126 when you go above this you get infinity and that is probably what you got.. But it would be nice if it printed out INF instead of 1.#INF.
Posted: Fri Feb 22, 2002 6:09 pm
by BackupUser
Restored from previous forum. Originally posted by Danilo.
The following works:
Code: Select all
x.f = 1.0
y.f = 1.000001
For i = 1 To 10000000
x = x * y
Next i
MessageRequester("Information", "x = " + StrF(x,10), 0)
I only changed your "100000000" to "10000000",
so i looks like a overflow (like Pupil said).
(registered PureBasic user)
Posted: Sat Feb 23, 2002 2:09 am
by BackupUser
Restored from previous forum. Originally posted by wongchunkit.
Thanks.
Yes, I know it is the over-flow problem. However, there is no such problem in VB or VBA.
A Registered Beginer on PureBasic,
Wong Chun Kit