facebook / facebook/hermes

Intl.NumberFormat notation: compact is not working on 0.71.7

Open
#1,035 22 comments 20 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
11.3k
Forks
859
Avg merge
1h 30m
Merged PRs (30d)
3

Description

## Bug Description

- [x] I have run `gradle clean` and confirmed this bug does not occur with JSC

Hermes version: {
"Bytecode Version": 90,
"Builtins Frozen": false,
"VM Experiments": 0,
"Build": "Release",
"GC": "hades (concurrent)",
"OSS Release Version": "for RN 0.71.7",
"CommonJS Modules": "None"
}

React Native version (if any): 0.71.7"
OS version (if any): 0.71.7"
Platform (most likely one of arm64-v8a, armeabi-v7a, x86, x86_64): all

## Steps To Reproduce

1. Use Intl.NumberFormat with large number and notation as compact

code example:

```
function formatCompactNumber(number) {
const formatter = Intl.NumberFormat("en", { notation: "compact" });
console.log(formatter.format(number));
}

// the comments are what should be logged
formatCompactNumber(-57); // -57
formatCompactNumber(999); // 999
formatCompactNumber(8_554); // 8.5K
formatCompactNumber(150_000); // 150K
formatCompactNumber(3_237_512); // 3.2M
formatCompactNumber(9_782_716_897); // 9.8B
formatCompactNumber(7_899_693_036_970); // 7.9T

// below is what we got:
/*
LOG -57
LOG 999
LOG 8,554
LOG 150,000
LOG 3,237,512
LOG 9,782,716,897
LOG 7,899,693,036,970
*/
```

## The Expected Behavior

Expected:

```
formatCompactNumber(150_000); // 150K
formatCompactNumber(3_237_512); // 3.2M
formatCompactNumber(9_782_716_897); // 9.8B
formatCompactNumber(7_899_693_036_970); // 7.9T
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.