|
| | | | N U M C O N V
| | | | |
numconv-0.1
------------
---
This is 'numconv' a program that allows to convert between four most common
numeral systems(BIN - 0b/%, OCT - 0o/q, DEC, HEX - 0x/$). It also detects
overflows and NaNs and informs about them using '$RC' environment variable.
Signed or unsigned 32/64 bit integers are supported.
---
NOTES:
[*]
Requires 68020(no FPU)+, OS2.04(theoretically)+, 6+ kilos of free memory.
[*]
Please note that notation detection depends on type of prefix. This of
course does not apply to the decimal format.
[*]
All notations allow signedness either at the input and output, this may be
very handy when there is a need to convert back.
---
HELP:
> numconv ?
INTEGER,B=BIN/S,O=OCT/S,I=DEC/S,H=HEX/S,A=ALIGN/S,S=SPFX/S,W=WPFX/S,
U=UNSIGNED/S,Q=QUAD/S,L=ABS/S
INTEGER - Integer to be examined or converted. This input can be
digit grouped as all common/mixed standards are handled.
B=BIN/S - Output notation is binary.
O=OCT/S - Output notation is octal.
I=DEC/S - Output notation is decimal(default).
H=HEX/S - Output notation is hexadecimal.
A=ALIGN/S - Align the output to maximum number of zeros. Amount of
0's depends on word width.
S=SPFX/S - Append single character prefix.
W=WPFX/S - Append double character prefix.
U=UNSIGNED/S - Operate only on unsigned integers. Whenever negative
value is passed when this is turned on then overflow
will occurr.
Q=QUAD/S - Extend the word width to 64 bits. By default 32bit ops
are used.
L=ABS/S - Makes the negative value positive when in signed mode.
---
USAGE:
; Convert decimal to binary
numconv 2013 b
; Get rid of digit grouping
numconv 1,000,000
; Convert freaky notation
numconv "22,1000'000 99" q
; Check if input is a number
failat 11
numconv >NIL: bo0
if error
echo "Oops, NaN was detected, me is scared!"
endif
; Check for overflow if any
failat 11
numconv >NIL: -1 u
if warn
echo "Oops, value passed in is out of range!"
endif
---
megacz
| |
| | | | |
|