Data Sheet
dScript
dScript User Manual v2.15
Formatting negative numbers
When the number is negative a '–' sign is placed in front of the number. If you are specifying a
width then this '–' sign counts as one of your characters.
X = -59
S1 = “Variable X is “ + {D} X
results in “Variable X is -59
S1 = “Variable X is “ + {D04} X
results in “Variable X is -059
The '-' sign is never displayed when formatting in binary or hexadecimal formats. This is
normal, because when using binay or hex you want to see what is contained in that variable
without regard to what the value represents. As the variables are 32 bits wide the full 32 bit
value is used.
S1 = “Variable X is “ + {H02} X
results in “Variable X is FFFFFFC5
S1 = “Variable X is “ + {B08} X
results in “Variable X is 11111111111111111111111111000101
If you are certain your value is contained in a smaller number of bits then the upper bits can
be masked out. For example you may want to display the value that has come in from a serial
port. You know this is only 8 bits so the upper bits can be masked out with:
X = X & 0x000000FF
which is the same as:
X = X & 0xFF
now,
S1 = “Variable X is “ + {H02} X
results in “Variable X is C5
and,
S1 = “Variable X is “ + {B} X
results in “Variable X is 11000101
Copyright © 2016, Devantech Ltd.
All rights reserved.
www.robot-electronics.co.uk
23