Skip to content

rounded_ln, rounded_log10 and rounded_exp still take only 64-bit arguments #20

Description

@christianparpart

What happens

With #12, a Rational holds a 128-bit numerator and denominator. The kernel behind rounded_ln, rounded_log10 and rounded_exp (include/formula-cpp/detail/transcendental.hpp) still takes only arguments whose numerator and denominator fit 64 bits. It narrows them with narrow_to_int64 and refuses the rest with Overflow.

  • rounded_ln of 2^70 is Overflow, though 2^70 is an ordinary Rational now and its logarithm is an ordinary number.
  • rounded_log10 refuses the same wide arguments. The exception is a power of ten up to 10^±38, which decimal_log answers exactly before the kernel is asked.
  • rounded_exp refuses arguments above 44 at up to 18 places, a bound derived for 64 bits. At those places e^45 would fit in 128 bits.

This is documented in docs/expressions.md, in the rounded_transcendental.hpp comments, and in the headroom page's "What this does not decide". It is pinned by tests (ln 2^70 and exp 2^-64 refuse; ln 2^62 and exp 2^-62 answer).

Refusing is safe: a refusal is never a wrong number. But it is a limit the 128-bit change did not lift.

Expected

The kernel takes 128-bit arguments and answers everywhere its result fits the requested places. The range reduction, the series and the rounding work in widths that cover a 128-bit argument; the 256-bit integers already used by the least-squares kernel are a model. rounded_exp's argument bound follows from 128 bits.

The pinned refusals then turn into pinned answers. The docs that state the 64-bit bound are updated, and the headroom page's "What this does not decide" loses its entry.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions