Re: Correct parsers for bounded integral values
Jeff Clites via Haskell-Cafe <[email protected]> Thu, 7 Aug 2025 17:37:11 -0700
| Newsgroups | gmane.comp.lang.haskell.cafe |
|---|---|
| Message-ID | <[email protected]> |
Thanks Brandon for the info. I don't fully understand the implications of having the carry bit set on the resulting 128-bit value, but that's okay. One thing I noticed about this: > On Jul 20, 2025, at 5:50 PM, Brandon Allbery <[email protected]> wrote: > > [...] > That it otherwise behaves as modular is in support of this, not in support of a mathematical law, and the behavior might differ on other architectures (e.g. PPC, or if someone somewhere still has a processor using 1s- complement). Which is the most important point: the Report specifies `Integral` types other than `Integer` to behave like the machine type, and you're basically assuming x86-64 (_probably_ also AArch64 but i haven't studied that one, just assuming it's 2s-complement) if you assume either modular arithmetic or any other behavior. The only promise you get is "matches the underlying hardware". Actually, this section of the Report: https://www.haskell.org/onlinereport/haskell2010/haskellch18.html#x26-22300018 says this: This module provides signed integer types of unspecified width (Int) and fixed widths (Int8, Int16, Int32 and Int64). All arithmetic is performed modulo 2^n, where n is the number of bits in the type. So that seems to contract the idea that they are just meant to match the underlying hardware. Jeff _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.