salimsaid
salimsaid

Reputation: 3495

Implementing a 64bit integer using 32bit integers

I am implementing an opcua server from specification. Opcua encodes datetime as a 64bit signed integer. The server will run on a 32bit embedded system that doesn't include(support) standard 64bit integers. I've tried looking online but i can't see useful articles on the subject. I also know that floating point numbers can be implemented from an open stadard from IEEE , but i don't seem to find a standardized representation for 64bit integers. I am using ansi C for the project. Where can i get some sort of material,content to get me started on the task ?

Upvotes: 1

Views: 89

Answers (1)

Jörg W Mittag
Jörg W Mittag

Reputation: 369458

You can implement a 64 bit integer using 2 32 bit integers in exactly the same way that you can implement a 2-digit integer from 2 1-digit integers. In other words, what you have is nothing but a 2-"digit" number in base 232.

If you know how to count beyond 9 using only digits 0-9, then you know how to count beyond 232 using only "digits" 0-232, because it is the exact same thing.

Upvotes: 1

Related Questions