|
From: andy p. <bod...@gm...> - 2026-06-07 22:32:19
|
On Sun, 7 Jun 2026 at 15:59, Luca Toniolo <lu...@ai...> wrote: > Fair, the magnitude case is rare and I won't push it. But the behaviour at the limit differs. An integer counter wraps at a known point and we already reconstruct it: hal_extend_counter() extends limited-width counters to 64 bits with the usual modular trick, so the count just keeps going, no discontinuity, no lost counts. A float past 53 bits doesn't wrap, it degrades silently, x + 1 == x and the count eventually sticks, with no boundary to detect and nothing to recover. So where it matters, the integer keeps counting correctly and the float quietly loses count. A getter/setter interface could warn/error at this point. I _think_ that the underlying driver code would ask for a specific type back from the interface, it would be absolutely _only_ the pins that were all fungible doubles. The motivation is to make HAL easier for users. Doing this would make the conv_*_* components unnecessary. You can connect anything to anything. (and you are on your own if that's a silly thing :-) ) > Either way, magnitude isn't the only reason for integer pins. It's also the values that aren't counts: registers, status and fault words, masks. Those don't round or wrap, the bit pattern just has to survive, which a double can't do. sserial already carries them as hal_u32_t pins for exactly that reason. It does, but currently we have no 64-bit masks or registers. Worst-case if those appear the driver component would have to provide high-byte and low-byte HAL pins. > One honest question: what would bitslice and bitmerge operate on without an integer type? Their job is word-to-bits and bits-to-word. These would probably remain as 32-bit components. The pin-names would be the same, they could be connected freely to any other HAL pin, internally they would be interpreted as 32-bit ints and treated accordingly. (And bitslice would output 32 floats with values of 0 or 1) [1] [1] In Sinclair basic, on the Z80, "True" was 0xFF and "False" was 0x00. That seems like a better scheme, more resilient to single-bit flips by cosmic rays. -- atp "A motorcycle is a bicycle with a pandemonium attachment and is designed for the especial use of mechanical geniuses, daredevils and lunatics." — George Fitch, Atlanta Constitution Newspaper, 1912 |