to-float

The to-float operation converts the input value into a floating-point number (decimal number). It is based on PHP’s type casting rules for floats.

How It Works

  • Integer → Float
    • Whole numbers are converted to their decimal equivalent.
    • Example: 42 → 42.0
  • String containing a number → Float
    • Numeric strings are converted to a float.
    • Example: “1.25” → 1.25
  • Boolean → Float
    • true converts to 1.0
    • false converts to 0.0
  • Null → Float
    • null converts to 0.0
  • Non-numeric strings → Float
    • If the string does not start with a digit, the result is 0.0.
    • Example: “abc123” → 0.0
    • If the string starts with digits, PHP attempts to parse them as a number.
    • Example: “123abc” → 123.0
  • Arrays or objects → Error
    • Arrays and objects cannot be converted into floats. Attempting to do so will cause an error.

Examples

InputResult
4242.0
“1.25”1.25
“123abc”123.0
“abc123”0.0
true1.0
false0.0
null0.0
[1,2,3]❌ Error
{ foo: “bar” }❌ Error

Usage in PalDock

Use to-float when:

  • An API requires numeric values in float format.
  • You need to ensure consistent numeric formatting before sending data.
  • A field may contain string numbers that should be interpreted as floats.

Note: Be cautious with mixed strings like “123abc”. They will partially convert, which may not always be the desired behavior. If you require strict numeric-only values, combine to-float with validation rules.

References

Insights that
helps you grow

  • Release notes 2025/12/19
    We added country-based categorization. You can now categorize offers, integrations, and other items by a specific country, or keep them global across all markets. We also…
  • Release notes 2025/12/17
    More flexible lead rejection: based on validation rules, filters, or pingtree sales results, by source (iframe, API) or by partner (include / exclude). It is now possible to…
  • Case study: How Lender Orka Ventures Scaled Affiliate Operations
    Orka Ventures, an online lending group that wanted to scale fast across countries and onboard affiliates quickly. Their custom affiliate API and tracking layer soon…