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 ?
Asked
Active
Viewed 51 times
1 Answers
1
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.

Jörg W Mittag
- 363,080
- 75
- 446
- 653
-
do you mind sharing a little code snippet so i have something to build on top of ? – salimsaid Oct 21 '18 at 14:52
-
`234 = 4*10**0 + 3*10**1 + 2*10**2`. In general, a number written in base `b` as `x_0 x_1 x_2 x_3 … x_n` has the value `x_n * b**0 + x_n-1 * b**1 + x_n-2 * b**2 + … + x_0 * b**n`. Addition of two such numbers performed by adding `x_n` to `y_n`, `x_n-1` to `y_n-1` and so on, carrying over any overflow to the next place, if the result is larger than `b-1`. Multiplication is done place-wise and then adding together the intermediate results. This is essentially primary school stuff. – Jörg W Mittag Oct 21 '18 at 15:01