EPIC Enhanced Programmable IRC-II Client

set floating_point_precision

Synopsis

/set floating_point_precision [<number>]

Default: 16. With no number, set displays the current value. The value must be a non-negative integer; negative or nonnumeric values are rejected.

Description

Controls the significant-digit precision used by the shared ftoa number-to-string conversion helper when floating_point_math is on. The helper uses C's %g formatting: the number is rounded for text output, trailing fractional zeros are omitted, and scientific notation may be selected. This is a significant-digit count, not a fixed number of decimal places.

Zero uses %g's effective precision of one significant digit. It is not equivalent to turning floating-point math off. With that other setting off, ftoa ignores this precision, truncates the fractional part toward zero, and formats the result without a fractional part.

Current scope

In the current source tree, numeric values imported by json_explode use this helper when creating script variables. Changing the setting affects later conversions; it does not recalculate or recover precision in strings already stored.

This is not a universal precision control for each arithmetic operation. The expression evaluator formats floating tokens through a separate %Lf and canon_number path, normally starting with six fractional digits. Math functions using the RETURN_FLOAT macro also use their own formatting rather than ftoa. Increasing this setting does not increase the underlying floating-point arithmetic accuracy or change those separate conversion paths.

There is no setting-specific upper bound beyond ordinary integer handling, but formatted output is limited by the helper's buffer. Use a reasonable precision; arbitrarily large values do not create additional meaningful digits. The setting has no immediate callback and sends no IRC request.

Example

Use six significant digits for later ftoa-based conversions:

/set floating_point_math on
/set floating_point_precision 6

For that conversion path, 123.456789 becomes 123.457; setting precision to zero instead yields one significant digit, typically 1e+02. These examples describe conversion formatting, not an expression-evaluator precision guarantee.

Restore the default with /set floating_point_precision 16.

History

This setting first appeared in EPIC4-1.1.9.

Source references