Skip to content
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

Basic arithmetic over Rational{Bool} doesn't work #15161

Closed
jiahao opened this issue Feb 20, 2016 · 3 comments
Closed

Basic arithmetic over Rational{Bool} doesn't work #15161

jiahao opened this issue Feb 20, 2016 · 3 comments
Labels
needs tests Unit tests are required for this change

Comments

@jiahao
Copy link
Member

jiahao commented Feb 20, 2016

julia> true//true * true//true
ERROR: checked_mul not defined for Bool
 in * at rational.jl:188

Similar errors are thrown for the other basic arithmetic operations -, +, /, , ...

I'm not quite sure how arithmetic for this type ought to work. Note that not all arithmetic over Bools is closed, e.g. true + true == 2

@TotalVerb
Copy link
Contributor

Are there any applications for Rational{Bool}? The integers mod 2 are a field already, so fractions aren't needed. Bool is not quite the integers mod 2 anyway because of addition behaviour.

@nalimilan
Copy link
Member

I fixed this (without knowing) in #15294. It probably used to work before rationals switched to checked arithmetic recently:

julia> true//true * true//true
true//true

julia> true//true - true//true
0//1

julia> true//true + true//true
2//1

julia> true//true / true//true
true//true

julia> true//true \ true//true
true//true

I have no idea of whether this can be useful, but there isn't any reason not to support this either.

@tkelman
Copy link
Contributor

tkelman commented Mar 6, 2016

We should probably add tests for these if someone wants them to continue working as they do at the moment.

@tkelman tkelman added the needs tests Unit tests are required for this change label Mar 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs tests Unit tests are required for this change
Projects
None yet
Development

No branches or pull requests

4 participants