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
Str() Function Problem
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Pupil.
Use this command to get desired result
string.s=StrF(variable.f, decimals.l)
Hi!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
Use this command to get desired result
string.s=StrF(variable.f, decimals.l)
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
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
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
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by MrVainSCL.
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
Hi wongchunkitwongchunkit wrote:
It show me x = 1.#INF
What does it mean?
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
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Pupil.
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.It show me x = 1.#INF
What does it mean?
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Danilo.
The following works:
I only changed your "100000000" to "10000000",
so i looks like a overflow (like Pupil said).
(registered PureBasic user)
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)so i looks like a overflow (like Pupil said).
(registered PureBasic user)
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm