Using the string functions

How to assign floating-point values

Using normal notation

<?php
  $float_1 = 3.5;      // Must contain a decimal point
  $float_2 = -6.0;     // May be negative
  $float_3 = .125;     // Same as 0.125
  $float_4 = 1.;       // Same as 1.0
?>

Using exponential notation

<?php
  $exp_1 = 9.451e15;   // Expands to 9.451 × 1015
  $exp_2 = 6.022e+23;  // Plus sign is optional
  $exp_3 = 1.602e-19;  // Exponent may be negative
  $exp_4 = 9.806e0;    // Exponent may be zero
  $exp_5 = -1.759e11;  // Mantissa may be negative
  $exp_6 = 3e9;        // Mantissa may be a whole number
?>

Back