英文:
Representing a float as a hexadecimal
问题
我正在学习浮点数类型,例子是一个用十六进制表示的浮点数变量声明:
float f_in_hex = 0x1.59a8f6p8f
这是计算浮点数值的过程:
(1 * 16^0 + 5 * 16^-1 + 9 * 16^-2 + 10 * 16^-3 + 8 * 16^-4 + 15 * 16^-5 + 6 * 16^-6) * 2^8
所以,我知道前缀 0x 表示 基数为16,但我仍然不理解指数部分为什么从0开始,并且带有负值。
英文:
I'm studying the float-point type and the examples is a declaration of a variable float expressed as an hexadecimal
float f_in_hex = Ox1.59a8f6p8f
This is the computation to find the float value:
(1 * 16^0 + 5 * 16^-1 + 9 * 16^-2 + 10 * 16^-3 + 8 * 16^-4 + 15 * 16^-5 + 6 * 16^-6) * 2^8
So, I know what is the prefix Ox, that base is 16 but I still don't understand why the exponential part start from 0 and goes with negative values
答案1
得分: 1
它是负值,因为它在小数点后面。
16^(-1) 相当于 1/16 = 0.0625。
如果是正指数,它将变成一个很大的数。
希望你明白我的意思。
英文:
it's negative value because it's after the decimal point
16^(-1) is the same as 1/16 = .0625
if it was positive exponent it would be a big number.
hope you understand what i mean
答案2
得分: -1
这不是一个十六进制数字,首先 "Ox" 是字母 "O",不是零。然后,在所谓的十六进制数字中,有一个字母 "p",而十六进制数字只包括从 "a" 到 "f"。
英文:
that is not a hexadecimal number, firstly Ox is the letter O and it is not a zero, then within the supposed hexadecimal numbers there is a letter p, the hexadecimal numbers only cover from a-f
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论