How do the digits 1101004800 correspond with the number 20?

断了今生、忘了曾经 提交于 2019-12-22 04:56:27

问题


I'm trying to learn how to modify memory locations using C++ and when messing with MineSweeper, I noticed that when the clock's value in memory was 1101004800, it was 20 seconds into the game. The digits 1101529088 correspond with 21 seconds into the game. Can someone please explain to me how to convert between those 10-digit long numbers to base-10?


回答1:


They are using floats to represent the timer. Here is a program that converts your integers to floats:

#include <stdio.h>

int main() {
  int n = 1101004800;
  int n2 = 1101529088;

  printf("%f\n", *((float*)&n));
  printf("%f\n", *((float*)&n2));

  return 0;
}

Output:

20.000000
21.000000



回答2:


1101004800 decimal is 0x41A00000 hex, which is the IEEE-754 representation of 20.0. 1101529088 decimal is 0x41A80000 hex, which is the IEEE-754 representation of 21.0.



来源:https://stackoverflow.com/questions/6488641/how-do-the-digits-1101004800-correspond-with-the-number-20

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!