Setting a byte writes four bytes #317

Closed
Kaj-de-Vos opened this Issue Nov 26, 2012 · 1 comment

Projects

None yet

3 participants

@Kaj-de-Vos
Contributor
Red/System []

a: as-byte 1
b: as-byte 2
c: as-byte 3
d: as-byte 4
a: as-byte 0
print-wide [as-integer a  as-integer b  as-integer c  as-integer d  lf]

bash-4.0# ./test
0 0 0 0

@PeterWAWood
Contributor

The initialisation seems to be okay but the subsequent assignment seems to cause the problem as this program shows:

Code

Red/System []

a: as byte! 1
fill1: FFFFFFFFh
b: as byte! 2
fill2: FFFFFFFFh
c: as byte! 3
fill3: FFFFFFFFh
d: as byte! 4
fill4: FFFFFFFFh
if 1 = (as integer! a) [print ["a ok" lf]]
if 2 = (as integer! b) [print ["b ok" lf]]
if 3 = (as integer! c) [print ["c ok" lf]]
if 4 = (as integer! d) [print ["d ok" lf]]
print ["fill1: " fill1 lf]
print ["fill2: " fill2 lf]
print ["fill3: " fill3 lf]
print ["fill4: " fill4 lf]

a: as byte! 0
if 0 = (as integer! a) [print ["a ok" lf]]
if 2 = (as integer! b) [print ["b ok" lf]]
if 3 = (as integer! c) [print ["c ok" lf]]
if 4 = (as integer! d) [print ["d ok" lf]]
print ["fill1: " fill1 lf]
print ["fill2: " fill2 lf]
print ["fill3: " fill3 lf]
print ["fill4: " fill4 lf]

Output

a ok
b ok
c ok
d ok
fill1: -1
fill2: -1
fill3: -1
fill4: -1
a ok
b ok
c ok
d ok
fill1: -16777216
fill2: -1
fill3: -1
fill4: -1

I'll add a test of two to cast-test.reds

@dockimbel dockimbel closed this Nov 27, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment