i recently discovered %unixtime% and i use this to time things(delta between actions)
to be save i replaced it with %syssec_d% but discovered that this value resets every day(duhh) and that was causing other problems
to keep things simple i want to do this
Let,4,%unixtime%-1613000000
this will give me a 6 digit number which is small enough to write savely to the variable.
It is working great.
my question is:
is espeasy made for these large calculations?
large numbers in variable
Moderators: grovkillen, Stuntteam, TD-er
Re: large numbers in variable
ok.
that post learns me that when i convert a unixtime value (1607951606) to binary i get around 31 bits so unixtime does not fit a variable if it can only hold 22 bits
my question however was not if it will fit or not but if it can do these large calculations.
i assume that for calculations the ESPeasy software also reserves a certain addressable bit range(i hope 32 bits)
that post learns me that when i convert a unixtime value (1607951606) to binary i get around 31 bits so unixtime does not fit a variable if it can only hold 22 bits
my question however was not if it will fit or not but if it can do these large calculations.
i assume that for calculations the ESPeasy software also reserves a certain addressable bit range(i hope 32 bits)
Re: large numbers in variable
Like I said, the recent changes related to variables (also used in calculations) now use double instead of float.
So this allows for storing 32 bit (and even slightly more) int values without loosing decimals.
Meaning you can even multiply a 30 bit value with a 21 bit value and still not loosing decimals.
So values upto 2^51 - 1 will not loose decimals. (and of course negative values too)
So this allows for storing 32 bit (and even slightly more) int values without loosing decimals.
Source:float is a 32 bit IEEE 754 single precision Floating Point Number1 bit for the sign, (8 bits for the exponent, and 23* for the value), i.e. float has 7 decimal digits of precision.
double is a 64 bit IEEE 754 double precision Floating Point Number (1 bit for the sign, 11 bits for the exponent, and 52* bits for the value), i.e. double has 15 decimal digits of precision.
Meaning you can even multiply a 30 bit value with a 21 bit value and still not loosing decimals.
So values upto 2^51 - 1 will not loose decimals. (and of course negative values too)
Re: large numbers in variable
thanks TD-er
Who is online
Users browsing this forum: No registered users and 14 guests