Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • \$\begingroup\$ This doesn't match the requirements. The question says to use at least,the largest fixed size (unsigned) integer type. That type happens to be Word64 (or Word on a 64-bit system). The current answer can't even accept integers as input, only floating point values. It also gets the incorrect answer due to precision loss even when you allow a Double as input with Word ouput. Try it online! \$\endgroup\$ Commented Jan 27, 2020 at 8:10
  • \$\begingroup\$ Whoops, my last comment comment uses a number too big for a 64 bit Word, but here is one demonstarting the accuracy problem properly Try it online! \$\endgroup\$ Commented Jan 27, 2020 at 8:27
  • \$\begingroup\$ @Potato44 ty for your feedback! Since you have to import Data.Word, doesn't it mean that I can get away without having to support it? \$\endgroup\$ Commented Jan 27, 2020 at 8:49
  • \$\begingroup\$ Word is part of the prelude, I just had Data.Word imported because I was using Word64, but forgot to remove the import. Even if it was not the case that Word was in the prelude, my interpretation is you would still have to import it as it is part of the standard library. But @Deadcode would be better at ruling on that. Also you can write functions that accept Word64 without importing Data.Word if you make them polymorphic enough. \$\endgroup\$ Commented Jan 27, 2020 at 8:58
  • \$\begingroup\$ @Potato44 in any case I can mark my answer as non-competing. Thanks for teaching me something \$\endgroup\$ Commented Jan 27, 2020 at 9:04