Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 5,264
    • Issues 5,264
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 565
    • Merge requests 565
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell CompilerGlasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #17303
Closed
Open
Issue created Oct 04, 2019 by taylorfausak@trac-taylorfausak

Rounding always throws an arithmetic underflow exception when used with a ratio of natural numbers

I originally reported this in !1878 (closed).

Today I was surprised to find that round does not work at all for Ratio Natural values. For example:

>>> round (1 :: Ratio Natural) :: Natural
*** Exception: arithmetic underflow

As far as I can tell it's true regardless of the value of the Ratio Natural or the result type.

>>> round (1.5 :: Ratio Natural) :: Natural
*** Exception: arithmetic underflow
>>> round (1 :: Ratio Natural) :: Integer
*** Exception: arithmetic underflow

For comparison, rounding works fine for Rational, which is an alias for Ratio Integer.

>>> round (1 :: Rational) :: Integer
1
>>> round (1.5 :: Rational) :: Integer
2
>>> round (1 :: Rational) :: Natural
1
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking