Skip to content

0.4.2 "Trig Or Treat"

Choose a tag to compare

@tommyettinger tommyettinger released this 02 Nov 02:56
· 482 commits to main since this release

A day after Halloween, here's a little treat! Because I didn't bother to post a GitHub release for versions between 0.3.0 and this one (0.4.2), the changelog for all of this would be... quite long. As a quick summary for what came before this...

  • There's better joining code in Base.
  • TextTools is new with code used by Base and useful in toString().
  • Hasher uses a similar but not-identical algorithm now.
  • You can specify a limit on how many chars to use in Base.decimal().

What's new in this release? Mostly improvements to the speed and accuracy of TrigTools! Now we store both a sine table (mostly for backwards-compatibility, but it is used internally as well) and a cosine table (useful because cosine is symmetric across 0.0, so negative inputs are one quick Math.abs() call away from using the same code as positive ones). Calling TrigTools.cos() is now slightly faster than TrigTools.sin(), which was different before; cos() used to take almost twice as long as sin(), but that is only a roughly-3-ns difference. The sinSmoother() and cosSmoother() methods are also faster. I haven't actually benchmarked tanSmoother(), but it's nearly the same.

The other new change in this release is in BitConversion. I've been adding a few new methods recently that benefit from what JS can do now. JS provides Math.clz32(), but GWT doesn't use it, so we provide BitConversion.countLeadingZeros(n) (where n can be int or long), and that uses clz32() on JS and Integer.numberOfLeadingZeros() (or Long's version) on other platforms. Similarly, there's BitConversion.countTrailingZeros(n). These two methods count how many contiguous 0 bits are present in a number starting from either the leading side (the sign bit) or the trailing side (the 1's place). They're surprisingly useful for such a seemingly-narrow scope; some usage simply needs to measure how many bits there are before a 1 bit, and other usage... is more arcane.

I hope this release is useful! Happy Halloween!

Oh, that was yesterday. Uh, Feliz Dia de los Muertos, for another few hours!