Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7852149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:21:12+00:00 2026-06-02T19:21:12+00:00

System.Numerics.BigInteger lets you multiply large integers together, but is there anything of the same

  • 0

System.Numerics.BigInteger lets you multiply large integers together, but is there anything of the same type for floating point numbers? If not, is there a free library I can use?

//this but with floats
System.Numerics.BigInteger maxint = new BigInteger(int.MaxValue);

System.Numerics.BigInteger big = maxint * maxint * maxint;
System.Console.WriteLine(big);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T19:21:12+00:00Added an answer on June 2, 2026 at 7:21 pm

    Perhaps you’re looking for BigRational? Microsoft released it under their BCL project on CodePlex. Not actually sure how or if it will fit your needs.

    It keeps it as a rational number. You can get the a string with the decimal value either by casting or some multiplication.

    var r = new BigRational(5000, 3768);
    Console.WriteLine((decimal)r);
    Console.WriteLine((double)r);
    

    Or with a simple(ish) extension method like this:

    public static class BigRationalExtensions
    {
        public static string ToDecimalString(this BigRational r, int precision)
        {
            var fraction = r.GetFractionPart();
    
            // Case where the rational number is a whole number
            if(fraction.Numerator == 0 && fraction.Denominator == 1)
            {
                return r.GetWholePart() + ".0";
            }
    
            var adjustedNumerator = (fraction.Numerator
                                               * BigInteger.Pow(10, precision));
            var decimalPlaces = adjustedNumerator / fraction.Denominator;
    
            // Case where precision wasn't large enough.
            if(decimalPlaces == 0)
            {
                return "0.0";
            }
    
            // Give it the capacity for around what we should need for 
            // the whole part and total precision
            // (this is kinda sloppy, but does the trick)
            var sb = new StringBuilder(precision + r.ToString().Length);
    
            bool noMoreTrailingZeros = false;
            for (int i = precision; i > 0; i--)
            {
                if(!noMoreTrailingZeros)
                {
                    if ((decimalPlaces%10) == 0)
                    {
                        decimalPlaces = decimalPlaces/10;
                        continue;
                    }
    
                    noMoreTrailingZeros = true;
                }
    
                // Add the right most decimal to the string
                sb.Insert(0, decimalPlaces%10);
                decimalPlaces = decimalPlaces/10;
            }
    
            // Insert the whole part and decimal
            sb.Insert(0, ".");
            sb.Insert(0, r.GetWholePart());
    
            return sb.ToString();
        }
    }
    

    If it’s out of the precision range of a decimal or double, they will be cast to their respective types with a value of 0.0. Also, casting to decimal, when the result is outside of its range, will cause an OverflowException to be thrown.

    The extension method I wrote (which may not be the best way to calculate a fraction’s decimal representation) will accurately convert it to a string, with unlimited precision. However, if the number is smaller than the precision requested, it will return 0.0, just like decimal or double would.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use the BigInteger class from the System.Numerics but if i want
Can someone show me how to use the System.Numerics.BigInteger datatype? I tried using this
I'm using .NET 4 System.Numerics.BigInteger Structure and I'm getting results different from the documentation.
I'm using .NET 4's System.Numerics.BigInteger structure . I need to calculate the square (x
I opened System.Numerics at reflector to study how it works. But all methods at
.NET 4.0 now has a new data type, System.Numeric.BigInteger. From what I understand, this
using System.Numerics; double doubleNumber = Math.Pow(1000, 99); // = 1.0E+297 BigInteger bigBase = (BigInteger)bigNumber;
I have a property that returns System.Numerics.BigInteger . When I casting the property to
Now that biginteger (System.Numerics.BigInteger) support has been added in C# 4.0, it would be
I want to use System.Numerics.Complex in an unmanaged PInvoke scenario. Using ILSpy, I noticed

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.