Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
370 views
in Technique[技术] by (71.8m points)

c - printf ("%d", 0.0625) prints a zero while nearby values such as 0.0624 print absurd numbers as you would expect, why is 0.0625 different?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

as per CostantinoGrana

"Do you know how IEEE 754 works? The numbers which you say "give 0" are multiples of a not too negative negative power of 2. So when you store them in little endian, the 32 less significant bits, that are all 0, are the first thing you find in memory as int. Your int is 32 bits wide, thus 0."


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...