3 ms·
Isn't Haskell's "Int" an arbitrary-sized integer, while C's "int" is... like, whatever the compiler makes of it, typically a 32 or 64 bit int? With the ackerma
by perlgeek 9y ago
Isn't Haskell's "Int" an arbitrary-sized integer, while C's "int" is... like, whatever the compiler makes of it, typically a 32 or 64 bit int?
With the ackermann function, it's not obvious that the compiler can proof a lack of overflow, and optimize out the bigint-ness.
Since I can't see the graphs, I don't know what input ranges the author used, and thus can't tell if the C version even gave the correct answer.
- minitech 9y ago> Isn't Haskell's "Int" an arbitrary-sized integer That’s "Integer". "Int" is fixed-size.
- Sniffnoy 9y agoNo, Haskell's Int is a machine integer; if you want a bigint, you use Integer rather than Int.
- deleted 9y ago[deleted]
- stochastic_monk 9y agoAt least so far, int in C compilers on 32/64 bit architectures has always been 32 bits. It’s not good practice, but I’ve seen plenty of code assuming int/unsigned are 32 bits.
- flamedoge 9y agoC std says int has to be at least 16 bits. http://en.cppreference.com/w/cpp/language/types http://en.cppreference.com/w/cpp/language/types
- stochastic_monk 9y agoOh, absolutely. Like I said, it's bad practice, and that's because it's not guaranteed by the standard. I'm just saying it's done.