lmaq
V2EX  ›  问与答

PHP 进制转换问题 懂得进来帮帮忙

  •  
  •   lmaq · Sep 6, 2014 · 2758 views
    This topic created in 4292 days ago, the information mentioned may be changed or developed.
    已知十六进制 “F5” hexdec函数转换为十进制为 “245”
    如何将十六进制的 “F5” 转换为 “-11”
    在windows计算器中使用程序员模式选择字节可以正确转换,但在程序里怎么实现呢?
    4 replies    2014-09-06 12:31:11 +08:00
    ideaa
        1
    ideaa  
       Sep 6, 2014
    搜索手册 base_convert
    lmaq
        2
    lmaq  
    OP
       Sep 6, 2014
    @ideaa base_convert("F5",16,10); 同样输出 “245”
    bcxx
        3
    bcxx  
       Sep 6, 2014
    @lmaq 你需要的是补码么?那你把结果用 2^(总位数) - base_convert 出来的就好了吧?(不知道拍黄片里面有没有求补码的- -
    msg7086
        4
    msg7086  
       Sep 6, 2014
    pack and unpack 可以按照给定的要求(signed/unsigned)做转换。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   828 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 21:20 · PVG 05:20 · LAX 14:20 · JFK 17:20
    ♥ Do have faith in what you're doing.