|
|
![[home]](http://htdb.org/images/blank.gif) |
|
class: Numeric
${abs(integer)}
|
input | ${abs(-3.14)} |
|
yields | 3
|
${int(integer)}
|
input | ${int(-3.14)} |
|
yields | -3
|
|
input | ${int(3.14)} |
|
yields | 3
|
${random(integer)}
|
input | ${random(1000)} |
|
yields | 540
|
|
input | ${random(1000)} |
|
yields | 793
|
${prettyNumber(integer)}
|
input | ${prettyNumber(1234567)} |
|
yields | 1,234,567
|
${padZero(integer)}
|
input | ${padZero(3)} |
|
yields | 03
|
|
input | ${padZero(33)} |
|
yields | 33
|
${hex2base10(hex)}
|
input | ${hex2base10(ff)} |
|
yields | 255
|
|
input | ${hex2base10(cafebabe)} |
|
yields | 3405691582
|
${num2hex(number)}
|
input | ${num2hex(255)} |
|
yields | ff
|
|
input | ${num2hex(1964)} |
|
yields | 7ac
|
${signed(number)}
|
input | ${signed(-666)} |
|
yields | -666
|
|
input | ${signed(666)} |
|
yields | +666
|
${eval(expression)}
supported functions:
+ (addition), - (subtraction), * (multiplication),
/ (division), (modulus), ^ (exponentiation),
sin(), cos(), atan(), abs(), sqrt(), ln(), exp()
this code is derived from Robert B. Stout's SNIPPETS
code collection,
MicroFirm Function Library (MFL),
Copyright 1991-93
|
input | ${eval(1 + 1)} |
|
yields | 2
|
|
input | ${eval(3 * (sin(45) + 1))} |
|
yields | 5.55271
|
${itor(integer)}
due to limitations to the size of their imaginations,
really large numbers cannot be encoded into Roman Numeral.
|
input | ${itor(66)} |
|
yields | LXVI
|
|
input | ${itor(666)} |
|
yields | DCLXVI
|
|
input | ${itor(6666)} |
|
yields |
|
|
notes |
yields nothing due to overflow.
|
${rtoi(RomanNumerals)}
converts Roman Numerals back into integers.
|
input | ${rtoi(emacs)} |
|
yields | 1100
|
|
notes |
it tries its best, don't it?
|
|
input | ${rtoi(MCXVLI)} |
|
yields | 1136
|
|
input | ${rtoi(MMMMMMMM)} |
|
yields | 8000
|
|
notes |
imperfect representation of large numbers.
|
|
|