Ticket #7365 (closed bug: invalid)

Opened 8 months ago

Last modified 8 months ago

rem function in ghci changes result when using the Int type

Reported by: leonardo Owned by:
Priority: normal Milestone:
Component: GHCi Version: 7.4.1
Keywords: Cc:
Operating System: Windows Architecture: x86
Type of failure: Incorrect result at runtime Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

I define this function

congruent_modulo_n a b n = (rem a n) == (rem b n)

If the signature is:

congruent_modulo_n :: Integer->Integer->Integer->Bool

Then when I try this function in the ghci everything works perfect. If I use this signature:

congruent_modulo_n :: Int->Int->Int->Bool

Then for the following input I get False:

congruent_modulo_n (3^(113-1)) 1 113

Change History

Changed 8 months ago by michalt

I might be missing something but, I don't really see a bug here. 3^112 is way too big to fit into an Int, so it will overflow. On the other hand Integer is an arbitrary-precision integer and should be able to represent this number correctly...

Changed 8 months ago by igloo

  • status changed from new to closed
  • difficulty set to Unknown
  • resolution set to invalid

Agreed: Thanks for the report, but, this is just a case of Int overflow, not a bug in GHC.

Note: See TracTickets for help on using tickets.