incorrect output with '#,##0.00' format #2953

Open
opened 2023-05-22 23:57:38 +00:00 by jinjin9527 · 1 comment

SSF.format( "#,##0.00", 3.105 ) gives a result of '3.10' - it should be '3.11'.
It seems there is a bug in dec function.
Current version:
・get decimal part:
3.105 -> 0.104999998
・power the decimal part
Math.pow(0.1049998, 2) -> 10.49998
・round off powered decimal part
Math.floor(10.49998) -> 10

Shloud The logic be as below.
Math.pow(3.105,2) -> 310.5 -> Math.floor(310.5) -> 311 -> 311/100 -> 3.11

SSF.format( "#,##0.00", 3.105 ) gives a result of '3.10' - it should be '3.11'. It seems there is a bug in dec function. **Current version:** ・get decimal part: 3.105 -> 0.104999998 ・power the decimal part Math.pow(0.1049998, 2) -> 10.49998 ・round off powered decimal part Math.floor(10.49998) -> 10 **Shloud The logic be as below.** Math.pow(3.105,2) -> 310.5 -> Math.floor(310.5) -> 311 -> 311/100 -> 3.11
Owner

Thanks for reporting! There are a number of these cases that we need to investigate further.

Thanks for reporting! There are a number of these cases that we need to investigate further.
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: sheetjs/sheetjs#2953
No description provided.