rusackas commented on code in PR #43620:
URL: https://github.com/apache/superset/pull/43620#discussion_r3890370384


##########
superset-frontend/packages/superset-ui-core/src/number-format/factories/createMemoryFormatter.ts:
##########
@@ -38,11 +38,19 @@ function formatMemory(
         : ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB', 'RB', 'QB'];
       const base = binary ? 1024 : 1000;
 
-      const i = Math.min(
-        suffixes.length - 1,
-        Math.floor(Math.log(absValue) / Math.log(base)),
-      );
-      formatted = `${sign}${parseFloat((absValue / Math.pow(base, 
i)).toFixed(decimals))}${suffixes[i]}`;
+  let scaleIndex = absValue < 1 ? 0 : Math.floor(Math.log(absValue) / 
Math.log(base));
+  let i = Math.min(suffixes.length - 1, scaleIndex);
+
+  let scaledValue = absValue / Math.pow(base, i);
+
+  if (scaledValue >= base && i < suffixes.length - 1) {

Review Comment:
   The head checks the rounded value at this point, so this is addressed... 
though it came in when the branch caught up with `master`, which already had 
the same fix from #43549. See my comment on the main thread. Resolving.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to