-2

My Question is that: Is it possible to show (2^63::Int) in 128 bit in Haskell?

Because of Int abs (2^63::Int) will not work because of the Int, but What If I have a 128 bit computer or compiler is it possible then to show the result?

Of course if it is possible, then please show me the way :)

gazrobur
  • 141
  • 1
  • 13
  • I need with Int if it is possible on a 128 bit comp. or somehow... Of course with Integer it works, but my question was not about that – gazrobur Feb 18 '16 at 13:14
  • 5
    you have a 128bit computer? ... and a Haskell compiler for this? – Random Dev Feb 18 '16 at 13:20
  • 3
    Searching for "Haskell int 128bit" immediately leads to [`Data.FixedPoint`](https://hackage.haskell.org/package/FixedPoint-simple-0.6.1/docs/Data-FixedPoint.html) which provides an `Int128` data type (and even bigger types). There's also the [`Data.DoubleWord`](https://hackage.haskell.org/package/data-dword-0.3/docs/Data-DoubleWord.html) package. AFAIK the only guarantee for `Int` is that it has at least *29* bits. On 64bit machines it *may* allow for bigger values, but it's not guaranteed. – Bakuriu Feb 18 '16 at 13:22
  • 5
    It's utterly irrelevant what architecture you have. You can easily show 2⁶³ (or 2¹⁰⁰⁰, for that matter), on a 16-bit machine. Of course it won't use machine-sized number types, but why would that matter? Sure, machine-words give the fastest performance, but if you're _showing_ the entire number them performance is out the window anyway. – leftaroundabout Feb 18 '16 at 13:26

1 Answers1

2

According to the Report, this question is implementation specific:

The finite-precision integer type Int covers at least the range [-2^29, 2^29-1]. As Int is an instance of the Bounded class, maxBound and minBound can be used to determine the exact Int range defined by an implementation.

I know of no implementations for which maxBound :: Int is larger than 2^63-1.

Daniel Wagner
  • 145,880
  • 9
  • 220
  • 380