Joseph Wright skrev:
> Hello all,
>
> Those of you who take an interest in the LaTeX3 SVN may have noticed
> that I've just added the beginnings of a 'l3fp' module as part of expl3.
> This is intended to provide a set of floating point functions for LaTeX3.
[snip]
> In terms of input range, I've gone for 999999999.999999999 to
> +999999999.999999999. This should be sufficient for a wide range of
> purposes (for example, if you convert a dimen into a floating point
> number in units pt then you are safe for any dimen TeX can handle).
I was as confused by this as J.Fine, but it now seems clear that you've
implemented a fixed point arithmetic package that possibly will become
a floating point arithmetic package.
> The design of the internals of the package is loosely following the
> wellknown fp package. However, that package is rather slow, at least
> partly as it handles 18 digits either side of the decimal. The approach
> in l3fp currently delivers addition, subtraction, multiplication and
> division much faster than fp does (between about 8 and 15 times as fast
> for a large number of repeated calculations). I hope this makes the
> module fast enough for practical use.
>
> The next phase is to add some more complex functions. I'm planning to
> cover trigonometry, exponential/ln and roots, plus a pseudorandom
> number generator
That most standard libraries primarily provide a "uniform in $[0,1]$"
(or some open variation of that interval) PRNG doesn't mean it is the
most natural form of a PRNG. It is entirely reasonable for an l3 core
PRNG to primarily produce random bits or random integers, which could
then be converted to random floats if anyone asks for it; it's easier
than going the other way.
> and a few utility functions. They may take a while:
> getting it right is not that easy.
>
> Feedback on the module is very welcome, for example on which functions
> to provide, bugs (there are bound to be some), etc.
There are some standard floatingpoint arithmetic modules for MetaPost,
which could perhaps provide inspiration, but on closer inspection those
seem to rely on builtin primitives for logarithm and exponent (of
course, one can then take a look in mp.web to see how Knuth implemented
those while avoiding overflow and such, but the level of indirection is
then pretty high).
Two Meta*ish operations which could well be useful in LaTeX are
"Pythagorean addition" (known as hypot in the C library I think) and
"Pythagorean subtraction" (given one side and the hypothenuse, find the
other side).
Lars Hellström
