Roberto Sepúlveda Bravo Roberto Sepúlveda Bravo - 5 months ago 58
C Question

unsigned double in C?

I need to use unsigned double in C structure, but i can't compile.
An error says: short, signed or unsigned invalid for `myvar'

this is my code:

#include <stdlib.h>
#include <stdio.h>

struct eReg{
int key;
unsigned char a;
unsigned short int b;
unsigned double myvar;

Does anyone know what is wrong?

I did not know "unsigned double" equals "unsigned float", then I didn't knew I had to find the answer to my question as "unsigned floats in C?" Anyway after reading the post, I've accepted my question as "duplicate". I suggest deleting this question.


You can not have unisgned floating point types. Therefore no unsigned double or unsigned float. unsigned can only be applied to integer types like char short int and long. The reason we have unsigned integers is that they can store numbers twice as large, and can be better suited for handling binary data. I can't really think of much of an advantage to using unsigned floating point types. You could get a little more precision but this is probably not worth the effort of implementing it in hardware and software.