//To clarify:
unint32_t xVariable = 14000000UL;
unint64_t yVariable = 14000000000ULL;
//This prints OK:
Serial.println(xVariable);
//This fails:
Serial.println(yVariable);
Explore... Chat... Share...
// BigNumber l = (BigNumber)14000000000ULL;
BigNumber l = (BigNumber)1400000 * (BigNumber)10000;
l.printTo(p);
p.println();
martinayotte wrote:it seems that even gcc has trouble handling 64bits.
$ cat bn.cpp
void f(int);
void f(unsigned long long);
void g(void)
{
f(14000000000ull);
}
$ esp-open-sdk/xtensa-lx106-elf/bin/xtensa-lx106-elf-g++ -fno-exceptions -Os -S bn.cpp
$ cat bn.s
.file "bn.cpp"
.text
.literal_position
.literal .LC0, 1115098112, 3
.align 4
.global _Z1gv
.type _Z1gv, @function
_Z1gv:
l32r a2, .LC0
l32r a3, .LC0+4
addi sp, sp, -16
s32i.n a0, sp, 12
call0 _Z1fy
l32i.n a0, sp, 12
addi sp, sp, 16
ret.n
.size _Z1gv, .-_Z1gv
.ident "GCC: (crosstool-NG crosstool-ng-1.22.0-55-gecfc19a) 4.8.5"
martinayotte wrote:After digging the issue, trying also the famous BigNumber library, I've only figured out the following way to handle it :Code: Select all// BigNumber l = (BigNumber)14000000000ULL;
BigNumber l = (BigNumber)1400000 * (BigNumber)10000;
l.printTo(p);
p.println();
As we can see, the commented line isn't working too, gcc seems to handle this constructor as 32bits too, so I had to use the second declaration to create the BigNumber and make it working.
BigNumber l = (BigNumber)"14000000000";
uint64_t l = 12345678901ULL;
Serial.print(uint32_t(l / 100000));
Serial.println(uint32_t(l % 100000));
It takes about 20-25 seconds for home assistant c[…]
I tried to upgrade tof my sonoff basic R2 with the[…]
a problem Perhaps you want to define "Probl[…]
Rebooting your router will not give you a faster I[…]
There are no other notifications from esptool.py i[…]
Using the Arduino IDE, you'll learn how to set up […]
In this project, you will post to Twitter using an[…]
In this project, we will build a water level contr[…]
I guess I'm late, but I had the same problem and f[…]
Last night I received my first D1 Minis for a lear[…]
Although I am aware that this is an old post, I fe[…]