tcl::mathfunc fmaTcl 9.1 only
Gives X times Y plus Z with one rounding.
tcl::mathfunc::fma X Y Z
expr {fma(X, Y, Z)}
Description
Gives X times Y plus Z, rounded once at the end. A product and then a sum round twice, so fma(0.1, 10, -1) keeps the error of 0.1 that 0.1 * 10 - 1 loses.
Arguments
| Argument | Type | Default | Description |
|---|---|---|---|
| X | number | required | The first factor. |
| Y | number | required | The second factor. |
| Z | number | required | The number to add. |
Returns
A float.
Examples
% expr {fma(2, 3, 4)}
10.0
% expr {fma(0.1, 10, -1)}
5.551115123125783e-17
% expr {0.1 * 10 - 1}
0.0
Errors
% expr {fma(2, 3)}
not enough arguments for math function "fma"
-errorcode TCL WRONGARGS
% expr {fma(1, 2, 3, 4)}
too many arguments for math function "fma"
-errorcode TCL WRONGARGS
Facts
- Capability
- None.
- Tcl release
- Tcl 9.1 only.
- Since
- ztcl 1.0.0-beta.1