Why doesn't C have unsigned floats?

后端 未结 12 1637
名媛妹妹
名媛妹妹 2020-11-28 01:47

I know, the question seems to be strange. Programmers sometimes think too much. Please read on...

In C I use signed and unsigned integers a

12条回答
  •  自闭症患者
    2020-11-28 02:15

    I believe the unsigned int was created because of the need for a larger value margin than the signed int could offer.

    A float has a much larger margin, so there was never a 'physical' need for an unsigned float. And as you point out yourself in your question, the additional 1 bit precision is nothing to kill for.

    Edit: After reading the answer by Brian R. Bondy, I have to modify my answer: He is definitely right that the underlying CPUs did not have unsigned float operations. However, I maintain my belief that this was a design decision based on the reasons I stated above ;-)

提交回复
热议问题