BigInteger.ToString("F") giving Format Exception

This is the exception i am getting while running the code:

FormatException: format ‘F’ not implemented
System.Numerics.BigInteger.ToString (System.String format, IFormatProvider provider)
System.Numerics.BigInteger.ToString (System.String format)
GameManager.Start () (at Assets/Scripts/GameManager.cs:38)

Here is my code:

using UnityEngine;

using System.Collections;

using System.Numerics;

using Mono.Math;

public class GameManager : MonoBehaviour {

System.Numerics.BigInteger mynumber =  System.Numerics.BigInteger.Parse("18000000000000000000000000000000000001" );

void Start () {

	mynumber.ToString ("F" );

}

}

Please Help, what i am doing wrong.

You might need to specify the CultureInfo as the second parameter to the ToString such as:

Using a CultureInfo object that is culture-independent:

mynumber.ToString ("F", CultureInfo.InvariantCulture);

or, English (United States) based CultureInfo object:

mynumber.ToString ("F", CultureInfo.CreateSpecificCulture("en-US"));

Well, the error couldn’t be much clearer:

format ‘F’ not implemented
System.Numerics.BigInteger.ToString

So you can’t use the format F. Actually it looks like the Mono implementation of BigInteger doesn’t support ToString with a custom format at all.

I’m not sure which verion of BigInteger Unity is actually using, however i’ve found an implementation that only supports “X”, “G”, “D”, “x”, “g”, “d”. The Mono.Math implemenation of BitInteger doesn’t support ToString with a format string at all. Only ToString which takes a radix uint which defaults to “10”.