FieldtypeFloat
Stores a floating-point number
Supports single-precision (float) or double-precision (double) database columns.
float — returns 0.0 when blank (not ''). Zero and blank are equivalent due to
zeroNotEmpty behavior (see Notes).
// Get
$page->float_field // float 0.0 when blank)
(float) $page->float_field // same as above; explicit cast for clarity
// Set
$page->float_field = 3.14;
$page->float_field = ''; // clear the value
$page->save('float_field');$pages->find('float_field=3.14');
$pages->find('float_field>1.0');
$pages->find('float_field=""'); // no value
$pages->find('float_field>=1.5, float_field<=9.5'); // rangezeroNotEmpty: by default
0.0and blank are equivalent — there is no way to distinguish "no value" from "zero" unlesszeroNotEmptyis disabled in the field settings.
- Default precision is 2 decimal places. Set
precisionto a different integer, or-1to disable rounding. - Column type is
float(single-precision) by default. Switch todoublefor higher precision when needed. - Compatible fieldtypes:
Fieldtype,Float FieldtypeInteger,FieldtypeDecimal,FieldtypeText. - Database column:
float NOT NULLordouble NOT NULL.
Click any linked item for full usage details and examples. Hookable methods are indicated with the icon. In addition to those shown below, the Fieldtype class also inherits all the methods and properties of: Fieldtype, WireData and Wire.
Common
Additional methods and properties
In addition to the methods and properties above, Fieldtype
API reference based on ProcessWire core version 3.0.260