microsoft / dotnet

This repo is the official home of .NET on GitHub. It's a great starting point to find many .NET OSS projects from Microsoft and the community, including many that are part of the .NET Foundation.
https://devblogs.microsoft.com/dotnet/
MIT License
14.25k stars 2.2k forks source link

BigInteger does not work correctly in .NET 8 #1422

Closed anwarminarso closed 6 months ago

anwarminarso commented 6 months ago

BigInteger does not work correctly in .NET 8

When running this code with .NET 6 and .NET 7 it works fine. Why doesn't this code work when compiled with .NET 8? I've also added the System.Runtime.Numerics package reference but it still doesn't run.

This is my example code:

public static class Program
{
    public static void Main(params string[] args)
    {
        var value = new BigInteger(32000);
        var exponent = new BigInteger(64000);
        var modulus = new BigInteger(96123);
        var result = BigInteger.ModPow(value, exponent, modulus);
        Console.WriteLine($"Result: {result}");
    }
}
WeihanLi commented 6 months ago

Maybe you could post an issue here

https://github.com/dotnet/runtime/issues/new/choose

WeihanLi commented 6 months ago

Try adding a namespace using using System.Numerics;, works for me

using System.Numerics;

var value = new BigInteger(32000);
var exponent = new BigInteger(64000);
var modulus = new BigInteger(96123);
var result = BigInteger.ModPow(value, exponent, modulus);
Console.WriteLine($"Result: {result}");
anwarminarso commented 6 months ago

Sorry, I forgot to add using System.Numerics; to the question code example above.

The problem is that after compiling the file extensions .exe and .dll should be formed. Strangely, when compiled with .NET 8, the .dll extension file was not formed.

The strangest thing is that when I created a new project with the same source code (copy paste), when I compiled it with .NET 8 it worked normally.

I'm using VS 2022 version 17.8.2, Windows 11

btw, thank you for your response.