Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unsigned double in C++?

Why doesn't C++ support unsigned double syntax?

like image 722
lost3den Avatar asked Mar 26 '10 11:03

lost3den


People also ask

What is unsigned data type in C?

unsigned char is a character datatype where the variable consumes all the 8 bits of the memory and there is no sign bit (which is there in signed char). So it means that the range of unsigned char data type ranges from 0 to 255.

Can you have an unsigned double in C++?

C++ doesn't support unsigned floating point types because most floating point hardware doesn't support unsigned floating point types.

What is unsigned float in C?

The keyword unsigned uses to store all the bits for the magnitude of the number and always positive. Floating Point Types : Floating point numbers are stored in 32 bits with 6 digits of precision. Floating point numbers are defined in C by the keyword float.


2 Answers

Because typical floating point formats don't support unsigned numbers. See, for instance, this list of IEEE 754 formats.

Adding a numerical format that isn't supported by common hardware just makes life difficult for compiler writers, and is probably not considered worth the effort.

like image 114
unwind Avatar answered Oct 06 '22 09:10

unwind


C++ doesn't support unsigned floating point types because most floating point hardware doesn't support unsigned floating point types. Some graphics cards do work with unsigned floating point, but it's generally internal, not really visible to a program or user.

like image 20
Jerry Coffin Avatar answered Oct 06 '22 11:10

Jerry Coffin