I am trying to write some soft on 8051 uC in C. Problem is that the longest integer is equal 16 bits. Is it possible to create my own 32 bit unsigned integer variable? Of course it should support all operations like +, -, << etc.

If it is not possible what is alternative? For me the only way which comes to my mind is to have two 16 bit integers. But in that solution I think I can't use standard operators. During all operations I would have to remember modifing two integers.

Is there any better way?

Thanks in advance.

有帮助吗?

解决方案

If your compiler/libc implementation conforms to C99, you can use the

uint32_t

type to represent 32-bit unsigned integers. If it doesn't, you can still give

unsigned long

a try (print its sizeof to see how big it is).

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top