Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

BigInteger Log10 can produce incorrect result

Aperta Adatta ai principianti
#134,654 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
88/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
csharp
Ambito
backend

Direzione di ricerca

Inizia dalla posizione di BigInteger.cs collegata nell’issue e riproduci le chiamate generica e diretta a BigInteger.Log10 con BigInteger.Pow(10, 21306). Esamina il coefficiente utilizzato per la stima e verifica che la chiamata generica restituisca 21306 senza modificare il risultato corretto della chiamata diretta.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

area-System.Numerics untriaged
Description

BigInteger BigInteger.Log10 can produce an incorrect result for the IBinaryInteger<T> implementation. The coefficient 1292913986 / 2^32 is slightly below log10(2), so the estimate can be too small.

Reproduction Steps
using System;
using System.Numerics;

static T IntegerLog10<T>(T value) where T : IBinaryInteger<T> => T.Log10(value);

Console.WriteLine(IntegerLog10(BigInteger.Pow(10, 21306))); // Incorrect, prints 21305
Console.WriteLine(BigInteger.Log10(BigInteger.Pow(10, 21306))); // Correct, prints 21306
Expected behavior

Both should print 21306.

Actual behavior

The first invocation prints 21305, the second line is 21306.

Regression?

No, this API is new in .NET 11.

Known Workarounds

No response

Configuration

.NET SDK:
Version: 11.0.100-rc.1.26425.128
Commit: 3551975be0
Workload version: 11.0.100-manifests.a6e318ce
MSBuild version: 18.11.0-1.26425.128+3551975be

Runtime Environment:
OS Name: Mac OS X
OS Version: 27.0
OS Platform: Darwin
RID: osx-arm64
Base Path: /usr/local/share/dotnet/sdk/11.0.100-rc.1.26425.128

Other information

This appears to be off-by-one. https://github.com/dotnet/runtime/blob/0598ca0a45c1f29be94f889a1fc6e9b30c40ea64/src/libraries/System.Runtime.Numerics/src/System/Numerics/BigInteger.cs#L3958

it should probably be 1292913987L not 1292913986L.

Lingua principale
C#
Stelle
18.3k
Fork
5.6k
Merge medio
2g 17h
PR unite (30g)
615

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di dotnet/runtime

Tutte le issue di dotnet/runtime

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.