Skip to content
This repository has been archived by the owner on Jun 5, 2022. It is now read-only.

Changed return types of ceil, floor, round and (%) to return Int. #9

Closed
wants to merge 1 commit into from

Conversation

jutaro
Copy link

@jutaro jutaro commented Jul 21, 2015

Seems obvious to me.

@garyb
Copy link
Member

garyb commented Jul 21, 2015

This has been raised a few times, but there are a few problems doing this:

  • (%) intentionally operates on Numbers, as it's the only way to get modulo behaviour for non-Ints. You can already do this with mod for Int.
  • Using Int for the others restricts the acceptable values they can operate on to the range of Int32, significantly smaller than the range of integers that Number can safely represent.

@garyb
Copy link
Member

garyb commented Jul 21, 2015

Also 0.5 % 0.7 does not produce an Int, so the type isn't right for that either 😄

@paf31
Copy link
Contributor

paf31 commented Jul 21, 2015

We should probably document those functions to explain the types :)

@paf31
Copy link
Contributor

paf31 commented Jul 21, 2015

Maybe these belong in -integers?

@garyb
Copy link
Member

garyb commented Jul 21, 2015

Yeah, that would make sense.

@hdgarrood
Copy link
Contributor

We have floor, ceil, and round with the types @jutaro wanted in integers now, so I think this can be closed.

@hdgarrood hdgarrood closed this Apr 18, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants