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 (^) can break Int/Float type safety #529

Closed
mgold opened this Issue Mar 18, 2016 · 4 comments

Comments

Projects
None yet
2 participants
@mgold
Contributor

mgold commented Mar 18, 2016

Currently, exponentiation (^) : number -> number -> number. A negative integer power will yield a float, producing a float value typed as an Int.

base : Int
base = 10

power : Int
power = -3

bad : Int
bad = base ^ power

toFloat bad == 0.001 which can cause all kinds of havoc.

Perhaps the return value should be changed from number to Float.

@jvoigtlaender

This comment has been minimized.

Show comment
Hide comment
@jvoigtlaender

jvoigtlaender Mar 18, 2016

Contributor

Closing as a duplicate.

Contributor

jvoigtlaender commented Mar 18, 2016

Closing as a duplicate.

@mgold

This comment has been minimized.

Show comment
Hide comment
@mgold

mgold Mar 18, 2016

Contributor

I looked for if this had already been reported... where's the original?

Contributor

mgold commented Mar 18, 2016

I looked for if this had already been reported... where's the original?

@jvoigtlaender

This comment has been minimized.

Show comment
Hide comment
@jvoigtlaender
Contributor

jvoigtlaender commented Mar 18, 2016

@mgold

This comment has been minimized.

Show comment
Hide comment
@mgold

mgold Mar 18, 2016

Contributor

Ok thanks.

Contributor

mgold commented Mar 18, 2016

Ok thanks.

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