This example allows you to verify that the assignment between signed and unsigned integer types works correctly.
source
compile
sandbox
issues?
back to examples
CLS DIM sb AS SIGNED BYTE, ub AS BYTE DIM sw AS SIGNED WORD, uw AS WORD DIM sd AS SIGNED DWORD, ud AS DWORD PRINT " 8>16) "; sb = -42: sw = sb: IF sw <> -42 THEN: PRINT "(1)";: ENDIF sb = -42: uw = sb: IF uw <> $FFD6 THEN: PRINT "(2)";: ENDIF ub = 192: sw = ub: IF sw <> 192 THEN: PRINT "(3)";: ENDIF ub = 192: uw = ub: IF uw <> 192 THEN: PRINT "(4)";: ENDIF PRINT PRINT " 8>32) "; sb = -42: sd = sb: IF sd <> -42 THEN: PRINT "(1)";: ENDIF sb = -42: ud = sb: IF ud <> $FFFFFFD6 THEN: PRINT "(2)";:ENDIF ub = 42: sd = ub: IF sd <> 42 THEN: PRINT "(3)";: ENDIF ub = 42: ud = ub: IF ud <> 42 THEN: PRINT "(4)";: ENDIF PRINT PRINT "16> 8) "; sw = -42: sb = sw: IF sb <> -42 THEN: PRINT "(1)";: ENDIF sw = -42: ub = sw: IF ub <> $D6 THEN: PRINT "(2)";: ENDIF uw = 42: sb = uw: IF sb <> 42 THEN: PRINT "(3)";: ENDIF uw = 42: ub = uw: IF ub <> 42 THEN: PRINT "(4)";: ENDIF PRINT PRINT "16>32) "; sw = -42: sd = sw: IF sd <> -42 THEN: PRINT "(1)";: ENDIF sw = -42: ud = sw: IF ud <> $FFFFFFD6 THEN: PRINT "(2)";: ENDIF uw = 42: sd = uw: IF sd <> 42 THEN: PRINT "(3)";: ENDIF uw = 42: ud = uw: IF ud <> 42 THEN: PRINT "(4)";: ENDIF PRINT PRINT "32> 8) "; sd = -42: sb = sd: IF sb <> -42 THEN: PRINT "(1)";: ENDIF sd = -42: ub = sd: IF ub <> $D6 THEN: PRINT "(2)";: ENDIF ud = 42: sb = ud: IF sb <> 42 THEN: PRINT "(3)";: ENDIF ud = 42: ub = ud: IF ub <> 42 THEN: PRINT "(4)";: ENDIF PRINT PRINT "32>16) "; sd = -42: sw = sd: IF sw <> -42 THEN: PRINT "(1)";: ENDIF sd = -42: uw = sd: IF uw <> $FFD6 THEN: PRINT "(2) = ";uw: ENDIF ud = 42: sw = ud: IF sw <> 42 THEN: PRINT "(3)";: ENDIF ud = 42: uw = ud: IF uw <> 42 THEN: PRINT "(4)";: ENDIF PRINT
The instructions here refer to compiling the example from the command line. For Microsoft Windows
users we suggest using UGBASIC-IDE, which allows
you to download and compile each single example with just one click.
Are instructions for your specific home computer / console missing? First of all, check if your computer
is supported by clicking here. If so, since ugBASIC is a language which does not provide abstractions, it is possible
that this example will not work on your target. If you think this is an issue, please click here.
In order to compile the example, type this command on the command line:
Linux
ugbc.cpc -O dsk -o maths_relative_04.dsk maths_relative_04.bas
Windows
ugbc.cpc.exe -O dsk -o maths_relative_04.dsk maths_relative_04.bas
For Microsoft Windows users we suggest using UGBASIC-IDE, which allows
you to download and compile this example with just one click.
In order to compile the example, type this command on the command line:
Linux
ugbc.atarixl -O xex -o maths_relative_04.xex maths_relative_04.bas
Windows
ugbc.atarixl.exe -O xex -o maths_relative_04.xex maths_relative_04.bas
For Microsoft Windows users we suggest using UGBASIC-IDE, which allows
you to download and compile this example with just one click.
In order to compile the example, type this command on the command line:
Linux
ugbc.atari -O xex -o maths_relative_04.xex maths_relative_04.bas
Windows
ugbc.atari.exe -O xex -o maths_relative_04.xex maths_relative_04.bas
For Microsoft Windows users we suggest using UGBASIC-IDE, which allows
you to download and compile this example with just one click.
In order to compile the example, type this command on the command line:
Linux
ugbc.coleco -O rom -o maths_relative_04.rom maths_relative_04.bas
Windows
ugbc.coleco.exe -O rom -o maths_relative_04.rom maths_relative_04.bas
For Microsoft Windows users we suggest using UGBASIC-IDE, which allows
you to download and compile this example with just one click.
In order to compile the example, type this command on the command line:
Linux
ugbc.c128 -O prg -o maths_relative_04.prg maths_relative_04.bas
Windows
ugbc.c128.exe -O prg -o maths_relative_04.prg maths_relative_04.bas
For Microsoft Windows users we suggest using UGBASIC-IDE, which allows
you to download and compile this example with just one click.
In order to compile the example, type this command on the command line:
Linux
ugbc.c128z -O prg -o maths_relative_04.prg maths_relative_04.bas
Windows
ugbc.c128z.exe -O prg -o maths_relative_04.prg maths_relative_04.bas
For Microsoft Windows users we suggest using UGBASIC-IDE, which allows
you to download and compile this example with just one click.
In order to compile the example, type this command on the command line:
Linux
ugbc.c64 -O prg -o maths_relative_04.prg maths_relative_04.bas
Windows
ugbc.c64.exe -O prg -o maths_relative_04.prg maths_relative_04.bas
For Microsoft Windows users we suggest using UGBASIC-IDE, which allows
you to download and compile this example with just one click.
In order to compile the example, type this command on the command line:
Linux
ugbc.d32 -O bin -o maths_relative_04.bin maths_relative_04.bas
Windows
ugbc.d32.exe -O bin -o maths_relative_04.bin maths_relative_04.bas
For Microsoft Windows users we suggest using UGBASIC-IDE, which allows
you to download and compile this example with just one click.
In order to compile the example, type this command on the command line:
Linux
ugbc.d64 -O bin -o maths_relative_04.bin maths_relative_04.bas
Windows
ugbc.d64.exe -O bin -o maths_relative_04.bin maths_relative_04.bas
For Microsoft Windows users we suggest using UGBASIC-IDE, which allows
you to download and compile this example with just one click.
In order to compile the example, type this command on the command line:
Linux
ugbc.msx1 -O rom -o maths_relative_04.rom maths_relative_04.bas
Windows
ugbc.msx1.exe -O rom -o maths_relative_04.rom maths_relative_04.bas
For Microsoft Windows users we suggest using UGBASIC-IDE, which allows
you to download and compile this example with just one click.
In order to compile the example, type this command on the command line:
Linux
ugbc.pc128op -O k7 -o maths_relative_04.k7 maths_relative_04.bas
Windows
ugbc.pc128op.exe -O k7 -o maths_relative_04.k7 maths_relative_04.bas
For Microsoft Windows users we suggest using UGBASIC-IDE, which allows
you to download and compile this example with just one click.
In order to compile the example, type this command on the command line:
Linux
ugbc.plus4 -O prg -o maths_relative_04.prg maths_relative_04.bas
Windows
ugbc.plus4.exe -O prg -o maths_relative_04.prg maths_relative_04.bas
For Microsoft Windows users we suggest using UGBASIC-IDE, which allows
you to download and compile this example with just one click.
In order to compile the example, type this command on the command line:
Linux
ugbc.sc3000 -O rom -o maths_relative_04.rom maths_relative_04.bas
Windows
ugbc.sc3000.exe -O rom -o maths_relative_04.rom maths_relative_04.bas
For Microsoft Windows users we suggest using UGBASIC-IDE, which allows
you to download and compile this example with just one click.
In order to compile the example, type this command on the command line:
Linux
ugbc.sg1000 -O rom -o maths_relative_04.rom maths_relative_04.bas
Windows
ugbc.sg1000.exe -O rom -o maths_relative_04.rom maths_relative_04.bas
For Microsoft Windows users we suggest using UGBASIC-IDE, which allows
you to download and compile this example with just one click.
In order to compile the example, type this command on the command line:
Linux
ugbc.coco -O bin -o maths_relative_04.bin maths_relative_04.bas
Windows
ugbc.coco.exe -O bin -o maths_relative_04.bin maths_relative_04.bas
For Microsoft Windows users we suggest using UGBASIC-IDE, which allows
you to download and compile this example with just one click.
In order to compile the example, type this command on the command line:
Linux
ugbc.coco3 -O bin -o maths_relative_04.bin maths_relative_04.bas
Windows
ugbc.coco3.exe -O bin -o maths_relative_04.bin maths_relative_04.bas
For Microsoft Windows users we suggest using UGBASIC-IDE, which allows
you to download and compile this example with just one click.
In order to compile the example, type this command on the command line:
Linux
ugbc.mo5 -O k7 -o maths_relative_04.k7 maths_relative_04.bas
Windows
ugbc.mo5.exe -O k7 -o maths_relative_04.k7 maths_relative_04.bas
For Microsoft Windows users we suggest using UGBASIC-IDE, which allows
you to download and compile this example with just one click.
In order to compile the example, type this command on the command line:
Linux
ugbc.to8 -O k7 -o maths_relative_04.k7 maths_relative_04.bas
Windows
ugbc.to8.exe -O k7 -o maths_relative_04.k7 maths_relative_04.bas
For Microsoft Windows users we suggest using UGBASIC-IDE, which allows
you to download and compile this example with just one click.
In order to compile the example, type this command on the command line:
Linux
ugbc.zx -O tap -o maths_relative_04.tap maths_relative_04.bas
Windows
ugbc.zx.exe -O tap -o maths_relative_04.tap maths_relative_04.bas
For Microsoft Windows users we suggest using UGBASIC-IDE, which allows
you to download and compile this example with just one click.
If you have found a problem trying to run this example, if you think there is a bug or, more
simply, you would like it to be improved, open an issue for this example on GitHub.
Thank you!
open an issue
BACK TO EXAMPLES