Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
hex = Number(-59).toString(16)
十六进制是-3b
-3b
十六进制应该是ffffffffffffffC5
ffffffffffffffC5
谢谢你的帮助!
如果数字为负,则保留符号。特别是如果基数是 2,它会返回数字的二进制(零和一),前面有一个 - 符号,但是是二进制的补码。
这就是类型toString()方法的Number工作原理,它不输出二进制补码。
toString()
Number
换句话说,该toString()方法将数字转换为正数,显示其十六进制表示,如果该数字为负数,则在其前面加上一个减号-。
-