B4P handles all numerals as double precision floating point numbers, regardless of the uses, ranging from loop indices to scientific calculations. Two subtypes are suppported:
Numerals picked up from the B4P program code or read in from tables will initially carry along their original text representations, for example 0123.40. They are useful in case the leading and trailing zeros in numbers (like in postal codes and section numbers in document structures) need to be preserved. The string representation will be discarded immediately when any kind of algorithmic operations is applied, for exmaple additions (including adding 0), negations and mathematical functions. In all these cases, the subtype changes from numeral to plain numeral. No discardings take place on direct assignments and transactions without calculations done, e.g. a[] = b[];.
a[0] = 123.45;
a[1] = 007;
a[2] = 20.20;
a[3] = num( '1.5E-3' ); // String representation will not be included here
a[4] = 0.00;
for all variables( a[], b[] )
{
c[] = str(b[]); // Recover string representation
d[] = b[] + 0; // String representation gets dropped because a calculation has been made
e[] = str(d[]); // Convert back to string representation
echo;
echo("For following numeral : ", b[], " subtype: ", subtype(b[]) );
echo(" String representation : ", c[], " subtype: ", subtype(c[]) );
echo(" Converted to plain numeral: ", d[], " subtype: ", subtype(d[]) );
echo(" Back to string again : ", e[], " subtype: ", subtype(e[]) );
}
For following numeral : 123.45 subtype: numeral
String representation : 123.45 subtype: quoted string
Converted to plain numeral: 123.45 subtype: plain numeral
Back to string again : 123.45 subtype: quoted string
For following numeral : 007 subtype: numeral
String representation : 007 subtype: quoted string
Converted to plain numeral: 7 subtype: plain numeral
Back to string again : 7 subtype: quoted string
For following numeral : 20.20 subtype: numeral
String representation : 20.20 subtype: quoted string
Converted to plain numeral: 20.2 subtype: plain numeral
Back to string again : 20.2 subtype: quoted string
For following numeral : 0.0015 subtype: plain numeral
String representation : 0.0015 subtype: quoted string
Converted to plain numeral: 0.0015 subtype: plain numeral
Back to string again : 0.0015 subtype: quoted string
For following numeral : 0.00 subtype: numeral
String representation : 0.00 subtype: quoted string
Converted to plain numeral: 0 subtype: plain numeral
Back to string again : 0 subtype: quoted string