1. Numbers using underscore _
? 0x6000_0000_0000_0000&& ' long long 64bit
? 9_223_372_036_854_775_807&& ' max long long
? 0x0000_0000& ' long 32 bit
? 2_147_483_647& ' max long
? 0x0000% ' integer 16bit
? 32_767% ' max integer
? 0x00ub ' byte 8bit unsigned only (0 to 255)
? 2_55ub ' max byte
? 0x8000_0000_0000_0000 ' decimal type (hold values as unsigned long long)
? 18_446_744_073_709_551_615@ ' max usnigned long long (decimal type)
? 123_456_789.876_543_210@ ' decimal type 27 digits
? #FFFFFF, #FFFF00=-65535 ' HTML COLORS - NO underscore
? 46_000ud=date("9/12/2025")
Def t(x)=type$(x)
? t(12_456.123_4#)="Currency"
? t(1_012.232e-10~)="Single"
2. Structures. New type Currency. When we use offset without label (here c) now interpreter pick the first one here the c.
2.1 Using only offest
structure alfa {
c as currency
}
buffer mem as alfa*100
? len(mem)
return mem, 3:=123121.2345#
z=eval(mem, 3)
? type$(z)="Currency", z=123121.2345#
2.2 Casting Currency to byte offsets
buffer mem as byte*1000
? len(mem)
return mem, 0:=123121.2345 as currency
z=eval(mem, 0 as currency)
? type$(z), z
2.3 Casting from long long to currency (123.4567 they have the same bits but rendering with the last 4 digits as fractional part)
buffer clear mem as byte*1000
Return mem, 100:=1234567 as long long
? eval(mem, 100 as Currency)
2.4 Long Long have also a bug and that bug removed
structure cc {
d as integer*10
c as long long ' usigned long long (8 bytes)
}
buffer clear mem as cc*100
a=0xFFFF_FFFF_FFFF_FFFF
' unsigned long long are Decimal types
Print type$(a)="Decimal"
' but we fit it on 8 bytes (the first 64bit)
return mem, 10!c:=0xFFFF_FFFF_FFFF_FFFF, 4!d!9:=65535
z=eval(mem, 10!c)
Print type$(z)="Decimal", z=18446744073709551615@
k=sint(z) 'same bits as long long (signed) )is the number -1
Print type$(k)="Long Long", k=-1 ' so k is long long signed
b=eval(mem, 4!d!9)
? b, type$(b)="Currency" ' this is the unsigned type for long and integer
integer b1=sint(b, 2)
? b1=-1, type$(b1)="Integer"
2.5 A bigger example with structure (Buffers can be put/get using files)
module check3 {
structure compount {
s as integer*19 ' for string
st as integer ' for end point
c as currency
q as currency
}
buffer clear mem as compount*10
put(mem, 4,"Mc Donuts", 1.233#, 12)
put(mem, 5,"Hellios", 123.789#, 100.5)
open "saveme.dat" for output as #f
put #f, mem, 1
close #f
// narrow our buffer
buffer clear mem as compount*2
open "saveme.dat" for input as #f
get #f, mem, len(compount)*4+1
close #f
show(mem, 0)
show(mem, 1)
sub put(m, a, n as string, am as currency, qu as currency)
Return m, a!s:=n, a!st:=0, a!c:=am, a!q:=qu
end sub
sub show(m, a)
Print "Name:";LeftPart$(Eval$(m, a!s, 40), chr$(0)),
Print @(20),"Amount:";eval(m, a!c),@(40),
Print "Items:";eval(m, a!q)
end sub
}
check3
Δεν υπάρχουν σχόλια:
Δημοσίευση σχολίου
You can feel free to write any suggestion, or idea on the subject.