Freestanding pow answers NaN for a negative base and a large odd whole exponent (above 1e15)

Ouverte
#2,477 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
3/5
Temps estimé
1-2 jours
Accessibilité débutants
72/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
c
Domaine
backend

Piste de recherche

Start with src/freestanding/mini_libm.c and inspect eigs_pow's whole-number and odd-exponent checks. Reproduce the supplied program in a freestanding build, then run make freestanding-libc-diff and check the rows for 1e15 + 1, 2^53 - 1, 2^53 and 2^53 + 2. Done means the odd whole exponents produce -1.0 for a negative base, fractional exponents retain their domain answer, and the diff stays green.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

area:embed kind:silent-wrong

The freestanding maths library answers NaN for a finite negative base raised to a large odd whole exponent, where the system library answers a number.

Found while repairing the non-finite cases of that library's pow for #2444. This one is a FINITE argument, which that step does not touch.

Shows it

On a freestanding build linked against src/freestanding/mini_libm.c:

try:
    print of (pow of [-1.0, 1000000000000001.0])
catch e:
    print of [e.kind, e.message]

The system library prints -1.0 in every state of EIGS_STRICT. The freestanding library prints nan with the variable unset or 0, and raises pow: result is not a number (NaN has no defined value) with 1.

The cause: eigs_pow treats the exponent as a whole number only up to 1e15 in magnitude (y == floor(y) && fabs(y) <= 1e15); above that a negative base takes the fractional-exponent path. Every double at or above 2^53 is a whole number, and the odd ones between 1e15 and 2^53 are exactly representable.

Done when

  • eigs_pow decides whole and odd for every exactly represented exponent, also above 1e15, for a finite negative base (-1.0 among them).
  • The program above prints -1.0 in the three states, with no flag set.
  • A fractional exponent of a negative base keeps its domain answer, and make freestanding-libc-diff stays green with rows for the exponents 1e15 + 1, 2^53 - 1, 2^53 and 2^53 + 2.

— Claude DevBox

Langage dominant
C
Étoiles
3
Forks
7
Merge moyen
3 h 28 min
PR mergées (30 j)
270

Préparer son environnement

Ouvrir dans Codespaces

Lance le conteneur de développement du projet dans votre navigateur, avec votre propre compte GitHub.

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de InauguralSystems/EigenScript

Toutes les issues de InauguralSystems/EigenScript

Issues similaires

Plus d'issues C

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.