New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exponentiation of negative `Int`s #194

Closed
yjchoe opened this Issue Mar 11, 2015 · 1 comment

Comments

Projects
None yet
2 participants
@yjchoe

yjchoe commented Mar 11, 2015

Hello,

I recently noticed that exponentiation of negative Ints can result in non-integral numbers with the type Int. For example:

> i = 10%4
2 : Int
> i
2 : Int
> -i
-2 : Int
> 10^(-i)
0.01 : Int

So, for instance, I could produce the following error on my elm-repl session:

> j = 2^(-i)
0.25 : Int
> k = 1/4
0.25 : Float
> j == k
(Type mismatch error)

I think 0.25 being an Int makes little sense, but I am not sure what would be the appropriate fix for this. The options I can think of are returning a number, returning a Float, and making such expressions illegal. The current implementation of (^) simply calls a native JS function and has type number -> number -> number.

@evancz

This comment has been minimized.

Show comment
Hide comment
@evancz

evancz Sep 22, 2016

Member

Consolidated all the math related stuff into the #721 meta issue. Follow along there!

Member

evancz commented Sep 22, 2016

Consolidated all the math related stuff into the #721 meta issue. Follow along there!

@evancz evancz closed this Sep 22, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment