
[英]How do I get the decimal places of a floating point number in Javascript?
[英]Javascript Integers vs Floating Point memory - do number of decimal places affect memory?
有一些包含许多点的 svg 文件,对这些值进行大量计算...尝试优化计算和 memory:
浮点值存储的 memory 是整数的两倍:
// 5 is less memory than 5.6789
在浮点值内怎么样 - 小数位数越少需要更少的 memory?
// Does 5.12 require less memory than 5.12341234647839234798372938719
?
编辑:删除 PI 并替换为通用随机数。
Number
类型是双精度 64 位 IEEE 754 二进制浮点数。 All values (from 5 to 5.12341234647839234798372938719) occupy the same amount of memory (eight raw bytes of memory, with possible overhead from object wrapping, depending on engine), but precision is limited; 文字5.12341234647839234798372938719
表示错误的精度(例如5.12341234647839234798372938718
是相同的值)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.