Page 1 of 1

Posted: Thu Aug 15, 2002 5:08 am
by BackupUser
Restored from previous forum. Originally posted by pusztry.

How come when I run this does the t variable act like it is an integer as soon as I divide by 1000 so that I can show the number in seconds instead of milli seconds.

Code: Select all

 x = 1
y = 1.000001
t = GetTickCount_()
For i = 1 To 100000000
  x=x*y
Next i
t = (GetTickCount_() - t)
t = t / 1000
;Debug t
MessageRequester("Benchmark Results", "It took " + Str(t) + " seconds" + Chr(10) + "To run through 100,000,000 loops.", 0)
End
Thanks

Ryan

WinXP, PIII 800 MHz, 512MB RAM, SB Live 5.1, NVidia TNT 2 Ultra

Posted: Thu Aug 15, 2002 5:35 am
by BackupUser
Restored from previous forum. Originally posted by Danilo.

You forgot to specify type FLOAT for 't':

Code: Select all

t.f = GetTickCount_()
For i = 1 To 100000000
  x=x*y
Next i
t = (GetTickCount_() - t)
t = t / 1000
;Debug t
MessageRequester("Benchmark Results", "It took " + StrF(t,2) + " seconds" + Chr(10) + "To run through 100,000,000 loops.", 0)
End
Same problem with your variable: y = 1.000001
This variable is 1, because its not float.
Use y.f = 1.000001 for FLOATs...


cya,
...Danilo

(registered PureBasic user)

Posted: Thu Aug 15, 2002 5:46 am
by BackupUser
Restored from previous forum. Originally posted by PB.

> How come when I run this does the t variable act like it is an integer

Because you haven't told it to be of float type and you need to use StrF instead
of Str. Try the following and you'll see that it works:

Code: Select all

x = 1
y = 1.000001
t = GetTickCount_()
For i = 1 To 100000000
x=x*y
Next i
t = (GetTickCount_() - t)
result.f = t / 1000 ; Result = float type due to [b].f[/b] at the end.
Debug result ; Don't need to specify [b].f[/b] after the first time.
MessageRequester("Benchmark Results", "It took " + StrF(result) + " seconds" + Chr(10) + "to run through 100,000,000 loops.", 0)

PB - Registered PureBasic Coder