Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions Jint/Native/BigInt/BigIntPrototype.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Globalization;
using System.Numerics;
using System.Text;
using Jint.Native.Intl;
using Jint.Native.Object;
using Jint.Native.Symbol;
using Jint.Runtime;
Expand Down Expand Up @@ -53,9 +54,12 @@ private JsValue ToLocaleString(JsValue thisObject, JsCallArguments arguments)
var options = arguments.At(1);

var x = ThisBigIntValue(thisObject);
//var numberFormat = (NumberFormat) Construct(_realm.Intrinsics.NumberFormat, new[] { locales, options });
// numberFormat.FormatNumeric(x);
return x._value.ToString("R", CultureInfo.InvariantCulture);

// Use Intl.NumberFormat for locale-aware formatting
var numberFormat = (JsNumberFormat) Engine.Realm.Intrinsics.NumberFormat.Construct([locales, options], Engine.Realm.Intrinsics.NumberFormat);

// Use BigInteger overload to avoid precision loss
return numberFormat.Format(x._value);
}

/// <summary>
Expand Down
1 change: 1 addition & 0 deletions Jint/Native/Intl/IntlInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ protected override void Initialize()
{
["Collator"] = new(_realm.Intrinsics.Collator, PropertyFlags),
["Locale"] = new(_realm.Intrinsics.Locale, PropertyFlags),
["NumberFormat"] = new(_realm.Intrinsics.NumberFormat, PropertyFlags),
["PluralRules"] = new(_realm.Intrinsics.PluralRules, PropertyFlags),
["getCanonicalLocales"] = new(new ClrFunction(Engine, "getCanonicalLocales", GetCanonicalLocales, 1, PropertyFlag.Configurable), PropertyFlags),
["supportedValuesOf"] = new(new ClrFunction(Engine, "supportedValuesOf", SupportedValuesOf, 1, PropertyFlag.Configurable), PropertyFlags),
Expand Down
Loading