At the primitive level, TeX (other than LuaTeX) doesn't provide any support for floating point calculations. We have count and dimen registers which are (somewhat) convenient for implementing higher-level floating point code. The latter can look like floating points as the usual representation (in pt
) does include a decimal part. However, these are actually implemented by working in integer values: scaled points (sp
).
Depending on the accuracy desired, reasonable results can be obtained by using dimen
registers and stripping off the units. However, as the accuracy (5 dp) and range are limited, this is best for work where speed is of the essence. A lot of more 'classical' TeX work with floats is done that way as on older systems the speed gain was vital for the code to be usable.
The alternative is to code everything in integers and handle the conversions at the macro level. With e-TeX we can use \numexpr
, which offers some speed and clarity gain and allows expandable working. (One could do everything expandably in TeX90 by doing all of the maths in the macro layer: various packages implement such approaches, for example bigintcalc
.)
The key to notice here is that the performance is independent of the system they are running on: everything is going via the same integer-internal code. (The very small amount of system-dependent float code in TeX90 is not accessible to users.)
In terms of use of floats, most older LaTeX packages simply don't, or use non-expandable routes via dimens (see trig
for example, used to rotate graphics). The fp
package is perhaps the longest-standing implementation in macros of a more accurate approach, though it is not that heavily used by packages. Newer code, written for more powerful systems, will make greater use of macro-based floats. The obvious example is TikZ, which again uses the dimen-based method as-standard (though does have a more complex FPU too). The expl3
language includes an expandable FPU (again written in macros), and it is gaining usage: it is slower than a dimen-based approach but for the use cases it has been applied to thus-far this has not been a major issue. (Performance here is also better on some parts of parsing, etc., so is roughly comparable to the TikZ code across a range of operations, and gains a lot of precision: see known benchmarks for floating point calculations?.)
As noted in the question, for very heavy float use, TeX is not the best tool and one should consider either LuaTeX or pre-processing in other ways.
\tanh
Function - TeX - LaTeX Stack Exchange