« first day (1241 days earlier)      last day (1615 days later) » 

12:45 AM
@10Replies Have you looked at struct tm in the standard library? It (along with mktime, gmtime, localtime, strftime, etc.) can probably already handle your needs.
 
 
12 hours later…
12:43 PM
12 messages moved from Lounge<C++>
 
 
4 hours later…
4:54 PM
Hi everyone, I wonder why in calculating the range of float numbers, everyone does this: 1.(2^23-1) * 2^127 while the exponent part is 8 bits so when all of them are one it will be 255 which when put in the formula gives 2^(255-127) = 2^128 , so the correct range IMO should be 1.(2^23-1) * 2^128
 
isn't IEEE754 exponent of 255 always infinity?
 
Ohhh right... thanks
 
nwp
8 bit signed numbers typically go from -128 to 127.
So there is no 128.
 
@nwp yes but I think exponent in ieee754 is not signed, sign bit is a separate bit
 
Anyone have experience with alternatives to std::variant? I've got a variant with 68 types in it, compile times are ~30s per file because of std::visit, and some of the variant visitation code is pretty gnarly.
An example of the code (just imagine much larger instances of this in various places):
Node setExposedPosition(Node node, Vec2 p) {
    std::visit(overloaded {
      [p](auto& n, decltype(n.exposedPosition)* = nullptr) {
        n.exposedPosition = p;
      },
      [](auto&...) { }
    }, node);
    return node;
}
 
nwp
5:19 PM
boost::variant is the obvious alternative, but I do not expect faster compile times by it and I think there are subtle differences in the behavior.
 
5:51 PM
@aderchox It's...sort of signed. It uses what's sometimes called an "excess N" notation. It's basically an unsigned number with a fixed offset applied to it, so 0 represents the smallest exponent, and 0b11111110 represents the largest exponent. As @PeterT said, 0b11111111 represents various oddball things--with significand == 0, you have an infinity. if the significand != 0 you have a NaN (with different bit patterns in the significand to represent quiet and signaling NaNs).
 
6:17 PM
@JerryCoffin hi thanks, I understand the part you approved @PeterT but about the signed exponent, I'm not quite sure I understand what @nwp said. If we assume 2^(E-127) as an excess-127 exponent, still E=0 gives -127 and E=255 gives 128, there is a difference of 1 between these two(-127 to 128) and -128 to 127.
 
nwp
It's because you don't want +0 and -0 to be different numbers. There is only 0. So there is one extra number that makes it not symmetrical.
 
Also note that the offset you apply is basically arbitrary, so if you want to have -10 to +245, you can do that just as easily.
 
I know you want to teach me something :) but I didn't understand either of your comments... @JerryCoffin (have -10 to +245)? Maybe I have problem with the English of it. @nwp (you don't want +0 and -0)? but I read somewhere that ieee has two values for 0.
and which number is the extra number?
 
nwp
IEEE754 specifies the whole floating point number which has positive and negative 0. But it's made of non-floating point numbers which behave more like std::int8_t.
The extra number comes from distributing 256 states to numbers where you pretty naturally end up with -128 to 127 if you try to evenly distribute them.
-127 to 128 would be just as natural.
 
6:57 PM
@aderchox My only point there was that an excess-N notation lets you make the range arbitrarily asymmetrical.
In other words, making it nearly symmetrical is purely a consequence of somebody deciding that was a good idea (or at least not seeing an advantage to doing otherwise), not because it's how the representation works out (whereas -128 to +127 is a consequence of 2's complement representation).
@nwp Sort of. -128 to +127 actually is symmetrical in a way: it has the same number of negative and non-negative numbers. -127 to +128 would have more positive numbers than negative, and also more non-negative than negative, so I think there's a fair argument that -128 to +127 is more symmetrical.
 
s
 
@JL2210 t
 
oops. had that in my chat box from last time and must've clicked "send".
 
@JL2210 I'm pretty sure I've sent (for example) ls on chat at least a few times...
 
7:13 PM
cd ~/Downloads/source/z80emu++
ls
 
@JerryCoffin IIRC, the exponent range has been chosen to ensure that x and 1/x are representable as much as possible.
 
@JerryCoffin aha thanks
 
ls -lah representable
-rw-r--r--. 1 chronos chronos 0 Dec 4 14:23 representable
 
@JerryCoffin I thought about this offset myself too and that's exactly what I came up with. It's a good divider to not bias toward neither side.
 
@AProgrammer Not sure if they specifically had that in mind, but it is pretty much how things are anyway.
 
7:25 PM
@AProgrammer yes it's very nice
 
7:38 PM
Am I allowed to advertise a Code Review question so it can get answers? I'm probably impatient, but it's been a week and I've only got one (that I've fully implemented). I don't want to continue doing something bad if I am doing it.
 
7:58 PM
@JL2210 Sounds fairly harmless to me, anyway.
 
@JerryCoffin I tough my source was the IEEE standard, as a constraint on the exponent range for extended types. But I've only the 1985 version here and that wasn't there. To confirm or infirm I'd have to check the 2008 version (or the 2019 one, but I haven't read it yet) but I'm at home and can't access the IEEE site without being at work.
 
Here it is: codereview.stackexchange.com/questions/232962/… (haven't yet gotten a response from the answerer so can't post updated code)
 
8:39 PM
Hold on, I'm writing a follow-up.
 

« first day (1241 days earlier)      last day (1615 days later) »