uses "console"
' how to store (and do arithmetic) and recall/display unsigned 64-bit (8-byte) integer?
' 0 to 18,446,744,073,709,551,615
' alias uint64 windows data type
'From thinbasic help :
'Internally, a VARIANT is always 16-bytes in size
' %VT_R8 Double
' %VT_UI8 Quad (unsigned)
Dim var_01 as Number value = 876543210987654321
Dim var_02 as Ext value = 876543210987654321
dim var_03 as Quad value = 876543210987654321
dim var_04 as Variant value = 876543210987654321
const Digits value = 18' Specifies the maximum number of significant digits (1 to 18) desired in the result.
Printl "For the value 876543210987654321 which is 18 significant digits," & $crlf & "it seems to be the limit with str$"
printl ""
display(str$(var_01,Digits),"Dim var_01 as Number")
display(str$(var_02,Digits),"Dim var_02 as Ext")
display(str$(var_03,Digits),"Dim var_03 as Quad")
printl ""
printl string$(20,"*") & "press a key to continue" & string$(20,"*")
printl ""
waitkey
printl ""
printl "Internally, a VARIANT is always 16-bytes in size"
printl "%VT_R8 means Double"
printl "%VT_UI8 means Quad (unsigned)"
printl ""
display(str$(var_04,Digits),"dim var_04 as Variant" & " displayed via str$," & $crlf & "internally stored as " & VARIANTVT$(var_04) & " !!! Notice value change !!!")
display(VARIANT$(var_04),"dim var_04 as Variant" & " displayed via VARIANT$," & $crlf & "internally stored as " & VARIANTVT$(var_04))
display(var_04,"dim var_04 as Variant" & " displayed directly," & $crlf & "internally stored as " & VARIANTVT$(var_04))
printl ""
printl ""
printl ""
printl ""
printl string$(20,"*") & "press a key to continue" & string$(20,"*")
printl ""
waitkey
Printl "For the value 18446744073709551615 which is 20 significant digits," & $crlf & "the maximum number for uint64 according to msdn"
printl ""
Dim var_05 as Number value = 18446744073709551615
Dim var_06 as Ext value = 18446744073709551615
dim var_07 as Quad value = 18446744073709551615
dim var_08 as Variant value = 18446744073709551615
display(str$(var_05,Digits),"Dim var_05 as Number")
display(str$(var_06,Digits),"Dim var_06 as Ext")
display(str$(var_07,Digits),"Dim var_07 as Quad")
printl ""
printl string$(20,"*") & "press a key to continue" & string$(20,"*")
printl ""
waitkey
display(str$(var_08,Digits),"dim var_08 as Variant" & " displayed via str$," & $crlf & "internally stored as " & VARIANTVT$(var_04))
display(VARIANT$(var_08),"dim var_08 as Variant" & " displayed via VARIANT$," & $crlf & "internally stored as " & VARIANTVT$(var_04))
display(var_08,"dim var_08 as Variant" & " displayed directly," & $crlf & "internally stored as " & VARIANTVT$(var_04))
function display(what as string, varname as string)
printl (string$(30,"-"))
printl (" " & varname)
Printl "string = " & what
Printl "length = " & len(what)
end function
printl ""
printl string$(20,"*") & "press a key to exit" & string$(20,"*")
printl ""
waitkey
I can't achieve to make a variant store data as %VT_UI8 .
Bookmarks