• 关于有符号与无符号的字节


    经历过几个时期,一直都用无符串的,总感觉有一个符号位非常的不靠谱,编译器什么时候给你转一下类型,或者干了什么

    后来又觉得C嘛,不会管你的到底是-1/还是255,反正都一样,什么类型啊,都是浮动,不就是一段内存长这样嘛

    后来又变了,觉得unsigned char真是麻烦,还得这么长或者typedef unsigned char uint8;又或者#include<stdint.h>,然后就一律都是char *

    真到今天,md5函数里面,有一个内存转成字符串的,才深刻认识到,原来,对于字节流而言,符号位也是会影响的

    有符号数扩宽填充符号位,

    --------------------------------
    "%02X" 多了6个 F

    总结,字节流,还是使用uint8_t*吧,多个#include<stdint.h>不会死的

  • 相关阅读:
    Power of Cryptography
    Radar Installation
    Emag eht htiw Em Pleh
    Help Me with the Game
    89. Gray Code
    87. Scramble String
    86. Partition List
    85. Maximal Rectangle
    84. Largest Rectangle in Histogram
    82. Remove Duplicates from Sorted List II
  • 原文地址:https://www.cnblogs.com/linbc/p/3529919.html
Copyright © 2020-2023  润新知