Some work on operators for Integers (are double inside) and long type (are 32 bit inside). We can use long as arrays (we can make Structures in memory if we want 1,2,4 byte unsign values)
This is from Help system in M2000, write Help Buffer
structure stringA {
str as integer*20
}
structure beta {
Alfa as byte
align1 as byte*3
Kappa as long*20
name as stringA*10
kappa2 as double
}
Buffer clear alfa as beta*100
Print Len(alfa), len.disp(alfa)
Print 5*len(beta)+ beta("kappa"), beta("kappa")
Return alfa, 50!kappa!10:=50
sLong=4
\Return alfa, 5*len(beta)+ beta("kappa")+10*sLong! :=50 as long
\Print eval(alfa, 5*len(beta)+ beta("kappa")+40 as long)
Print eval(alfa, 50!kappa!10)
Return alfa, 50!name!5:="George", 50!name!6:="Hello"
Print eval$(alfa, 50!name!5, 20)
Print eval$(alfa, 50!name!6, 20)
Print Len(alfa), type$(beta)
So this revision isn't about those integers in structures.
First check the For Next (or with block). I change he way M2000 use Int() on start value, end limit, and step (here step used as absolute value, we can change how for next work, as Basic or as in M2000). The basic difference is than in M2000 mode, always the block run one time).
long a
for a=1.8 to 10 step 2.6 { \\ change to 1 10 int(abs(2.6))=2
print a ' 1 3 5 7 9
}
for a%=1.8 to 10 step 2.6 { \\ change to 2 10 3
print a% ' 2 5 8
}
for x=1.8 to 10 step 2.6 {
print x ' 1.8 4.4 7 9.6
}
And this is the final part for this revision, the operator /= for long values is a a division same as integer division in VB6, and can't change with switch "+div". A always get a value as long but before a Fix() function remove the decimal part.
But for integers like A%, is a normal division, and when we move the value to variable we get a conversion. A 2.5 change to 3 (a -2.5 change to -3).
Long a=-2.1
Print a ' -3
a=2.9
Print a ' 2
a=-2.6
Print a ' -3
long a=2.6
Print type$(a)
Print a ' 2
Let a=-2.6
Print a ' -3
Print type$(a) ' long
Print Int(-2.6), Int(2.6) ' -3 2
Print Int(-2.5), Int(2.5) ' -3 2
Print Int(-2.4), Int(2.4) ' -3 2
Print Round(-2.5,0), Round(2.5, 0) ' -3 3
Print Round(-2.4,0), Round(2.4, 0) ' -2 2
Let A%=-2.5, B%=2.5
Print A%, B% ' -3 3
Let A%=-2.4, B%=2.4
Print A%, B% ' -2 2
Check this too for /= operator.
A%=10
For i=1 to 5 {
A%/=2 ' 5 3 2 1 1
Print A%
}
A%=10
For i=1 to 5 {
A%=A% / 2 ' 5 3 2 1 1
Print A%
}
A%=10
For i=1 to 5 {
A%=A% div 2 ' 5 2 1 0 0
Print A%
}
Print Type$(A%) ' Double
A=10
For i=1 to 5 {
A/=2 ' 5 2.5 1.25 0.625 0.3125
Print A
}
Print Type$(A) ' Double
Long A=10
For i=1 to 5 {
A/=2 ' 5 2 1 0 0
Print A
}
A=10
For i=1 to 5 {
A=A / 2 ' 5 2 1 0 0
Print A
}
Print Type$(A) ' Long
A=10
Dim A(10)=10, A%(10)=10
swap A(3), A ' we can swap values, so A get a double as 10
Print Type$(A) ' Double
Print Type$(A(3)) ' long
Print A(3)*100 ' is a double as result
\\ long for array items not supported, except for swapping
For i=1 to 5 {
A(3)/=2 ' 5 2.5 1.25 0.625 0.3125 ' assign/alter only to double in array
Print A(3)
}
Print Type$(A(3)) ' Double
A=10
Print Type$(A) ' A is a Double
Long A ' Now A convert to long
Print Type$(A)
Print A ' value is 10
For A=1.9 to 10.9 {
Print A, ' from 1 to 10, because A is long
}
Print
Print A, Type$(A)
This is from Help system in M2000, write Help Buffer
structure stringA {
str as integer*20
}
structure beta {
Alfa as byte
align1 as byte*3
Kappa as long*20
name as stringA*10
kappa2 as double
}
Buffer clear alfa as beta*100
Print Len(alfa), len.disp(alfa)
Print 5*len(beta)+ beta("kappa"), beta("kappa")
Return alfa, 50!kappa!10:=50
sLong=4
\Return alfa, 5*len(beta)+ beta("kappa")+10*sLong! :=50 as long
\Print eval(alfa, 5*len(beta)+ beta("kappa")+40 as long)
Print eval(alfa, 50!kappa!10)
Return alfa, 50!name!5:="George", 50!name!6:="Hello"
Print eval$(alfa, 50!name!5, 20)
Print eval$(alfa, 50!name!6, 20)
Print Len(alfa), type$(beta)
So this revision isn't about those integers in structures.
First check the For Next (or with block). I change he way M2000 use Int() on start value, end limit, and step (here step used as absolute value, we can change how for next work, as Basic or as in M2000). The basic difference is than in M2000 mode, always the block run one time).
long a
for a=1.8 to 10 step 2.6 { \\ change to 1 10 int(abs(2.6))=2
print a ' 1 3 5 7 9
}
for a%=1.8 to 10 step 2.6 { \\ change to 2 10 3
print a% ' 2 5 8
}
for x=1.8 to 10 step 2.6 {
print x ' 1.8 4.4 7 9.6
}
And this is the final part for this revision, the operator /= for long values is a a division same as integer division in VB6, and can't change with switch "+div". A always get a value as long but before a Fix() function remove the decimal part.
But for integers like A%, is a normal division, and when we move the value to variable we get a conversion. A 2.5 change to 3 (a -2.5 change to -3).
Long a=-2.1
Print a ' -3
a=2.9
Print a ' 2
a=-2.6
Print a ' -3
long a=2.6
Print type$(a)
Print a ' 2
Let a=-2.6
Print a ' -3
Print type$(a) ' long
Print Int(-2.6), Int(2.6) ' -3 2
Print Int(-2.5), Int(2.5) ' -3 2
Print Int(-2.4), Int(2.4) ' -3 2
Print Round(-2.5,0), Round(2.5, 0) ' -3 3
Print Round(-2.4,0), Round(2.4, 0) ' -2 2
Let A%=-2.5, B%=2.5
Print A%, B% ' -3 3
Let A%=-2.4, B%=2.4
Print A%, B% ' -2 2
Check this too for /= operator.
A%=10
For i=1 to 5 {
A%/=2 ' 5 3 2 1 1
Print A%
}
A%=10
For i=1 to 5 {
A%=A% / 2 ' 5 3 2 1 1
Print A%
}
A%=10
For i=1 to 5 {
A%=A% div 2 ' 5 2 1 0 0
Print A%
}
Print Type$(A%) ' Double
A=10
For i=1 to 5 {
A/=2 ' 5 2.5 1.25 0.625 0.3125
Print A
}
Print Type$(A) ' Double
Long A=10
For i=1 to 5 {
A/=2 ' 5 2 1 0 0
Print A
}
A=10
For i=1 to 5 {
A=A / 2 ' 5 2 1 0 0
Print A
}
Print Type$(A) ' Long
A=10
Dim A(10)=10, A%(10)=10
swap A(3), A ' we can swap values, so A get a double as 10
Print Type$(A) ' Double
Print Type$(A(3)) ' long
Print A(3)*100 ' is a double as result
\\ long for array items not supported, except for swapping
For i=1 to 5 {
A(3)/=2 ' 5 2.5 1.25 0.625 0.3125 ' assign/alter only to double in array
Print A(3)
}
Print Type$(A(3)) ' Double
A=10
Print Type$(A) ' A is a Double
Long A ' Now A convert to long
Print Type$(A)
Print A ' value is 10
For A=1.9 to 10.9 {
Print A, ' from 1 to 10, because A is long
}
Print A, Type$(A)
Δεν υπάρχουν σχόλια:
Δημοσίευση σχολίου
You can feel free to write any suggestion, or idea on the subject.