2 ms·
It depends on the underlying representation. I know it's almost never anything except IEEE 754 now, but it could be different. When I was an undergrad doing th
by ja27 14y ago
It depends on the underlying representation. I know it's almost never anything except IEEE 754 now, but it could be different.
When I was an undergrad doing the ACM programming contest, one year we had this triangle problem where, given the length of the three sides, you had to print whether it was an equilateral, isosceles, right, or not a triangle at all. Lots of naive programmers (including me) just checked if (aa + bb) == c*c for a right triangle. The kicker is, for the (secret) test data, that worked fine if you used single-precision floats and failed if you used double-precision floats.
That educated a whole region of ACM contest competitors on floating point representations.
- sp332 14y agoAs Lexarius mentioned, IEEE 754 includes decimal representations. https://en.wikipedia.org/wiki/IEEE_floating_point#Basic_formats https://en.wikipedia.org/wiki/IEEE_floating_point#Basic_form...
- Evbn 14y agoHow did the spec specify input format?
- davidcuddeback 14y agoIn the ACM programming contests, input formats are usually ASCII text, read from STDIN or from a file.
- ja27 14y agoYes, ASCII text of three decimal values per line (if I'm remembering correctly): 3.0 4.0 5.0 4.0 4.0 8.0 One of my favorite sort of problem was one that could easily be solved if you could handle arithmetic with integers larger than 32/64 bit types.