[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
uint64_t usage
From: |
Rik |
Subject: |
uint64_t usage |
Date: |
Tue, 6 Oct 2015 11:04:37 -0700 |
After including "stdint.h", can I always rely on uint64_t being available
to the compiler? Or do I need to write complicated code with #ifdefs to
use either uint32_t or uint64_t?
I've written code for the parser to handle binary constants and it is
pretty simple as written.
---Code---
else if (looks_like_bin (tmptxt, strlen (tmptxt)))
{
uint64_t ivalue = 0;
for (int i = 0; i < strlen (tmptxt); i++)
{
ivalue <<= 1;
ivalue += static_cast<uint64_t> (tmptxt[i] == '1');
}
value = static_cast<double> (ivalue);
nread = 1; // Just to pass the assert stmt below
}
---End Code---
We could also have Octave only support 32-bit binary constants since I
think uint32_t is guaranteed.
--Rik