search

Home  >  Q&A  >  body text

c++ - printf 数据输出问题

ringa_leeringa_lee2804 days ago582

reply all(3)I'll reply

  • PHP中文网

    PHP中文网2017-04-17 13:57:09

    %x placeholder is used to output unsigned integer type. You are definitely wrong to use it to output floating point type.

    reply
    0
  • ringa_lee

    ringa_lee2017-04-17 13:57:09

    You can refer to: http://www.cplusplus.com/reference/cstdio/printf/

    x: is an unsigned hexadecimal integer

    Your first step has been to convert 0x00000001 to float


    Update for you:

    %X should not be the hexadecimal value of the output data

    Although it is hexadecimal, integers are the key points

    Your f1 is float

    float f1 = 0x00000001;

    reply
    0
  • 迷茫

    迷茫2017-04-17 13:57:09

    The underlying operation of floating-point numbers is different from that of integers. When floating-point numbers are operated, they have their own independent floating-point stack. Each register of the floating-point stack has 80 bits. The result used by printf("%x") is a direct floating-point number. Outbound results (results are expressed in 64 bits), so not 32 bits

    reply
    0
  • Cancelreply