Squares

General FreeBASIC programming questions.
dodicat
Posts: 5655
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Squares

Postby dodicat » Apr 16, 2019 9:49

val (double) is good for ulong, you can use double for a 32 bit colour for example.
But for ulongint, double is not accurate.
Example:

Code: Select all



dim as ulong ul=4294967196
dim as ulong aul(1 to 50)
for n as long=1 to 50
    aul(n)=ul+n
next
for n as long=1 to 49
   if val(str(aul(n+1)))-val(str(aul(n))) <>0 then
    print n,vallng(str(aul(n+1)))-vallng(str(aul(n))), val(str(aul(n+1)))-val(str(aul(n)))
end  if
next

print "Press a key . . ."

sleep
dim as ulongint u=18446744073709051616

print
dim as ulongint au(1 to 100000)
for n as long=1 to 100000
    au(n)=u+n
next

for n as long=1 to 99999
   if val(str(au(n+1)))-val(str(au(n))) <>0 then
    print n,valulng(str(au(n+1)))-valulng(str(au(n))), val(str(au(n+1)))-val(str(au(n)))
    end if
next
sleep
 

double might be OK for lossy compression (pictures, sounds . . . ), but if you use 64 character jumps in strings then you need ulongint and ulongint functions.
(That's my guess anyway)

Return to “General”

Who is online

Users browsing this forum: No registered users and 4 guests