Numbers

Prev Next

Introduction

B4P considers theb following numbers:

  • It must contain at least one digit (0..9)
  • Negative numbers must precede with a minus sign (see also: unary operators)
  • One decimal point per number may be used:
    • .1 represents the same value as 0.1
    • 1. represents the same value as 1
    • A lone decimal point . is interpreted as text.
  • The synatx itself does not foresee scientific notation and thousand sparators or spaces between digits. There are other ways to specify them, for example with dedicated functions.

Good Examples Interpretation Bad Examples Interpretation
12 Number 1 2 Text "1 2"
1234.50 Number 1,234.50 Syntax error (comma)
.1 Number (0.1) . Text (point)
num(1.2E3) Use function for scientifi notation 1.2E3 Text "1.2E3"


       echo( 1 );                   // Simple numeral
       echo( 1 1 + 2 2 );           // Attention: These two numbers are strings : '1 12 2' is returned, not '33' or '3 3'
       echo( 123.45 );
       echo( 0123.450 );            // Same value as above.  B4P retains the original "look" if no calculations are applied.
       echo( 0123.450 *1);          // Operation applied (multplied by 1), therefore text representation has been dropped
1
1 12 2
123.45
0123.450
123.45
Try it yourself: Open LAN_Features_Number.b4p in B4P_Examples.zip. Decompress before use.

See also

Numerals
Scientific Notation