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

Addition and substraction of UnitRanges and StepRanges #35370

Closed
bkamins opened this issue Apr 6, 2020 · 1 comment
Closed

Addition and substraction of UnitRanges and StepRanges #35370

bkamins opened this issue Apr 6, 2020 · 1 comment

Comments

@bkamins
Copy link
Member

bkamins commented Apr 6, 2020

Following the discussion on Slack.

Currently this works :

julia> (1:2) - (1.0:2)
0.0:0.0:0.0

But these operations fail:

julia> (1:2) - (1:2)
ERROR: ArgumentError: step cannot be zero

and

julia> (1:1:2) - (1:1:2)
ERROR: ArgumentError: step cannot be zero

It would be more consistent to allow them, but then internal design of UnitRange and StepRange would need to change (and a tricky part is that the length can span from 0 to 2^(sizeof(type)*8) which is just one value too much to use the same storage type for values and for length).

Additionally we have the following problems with ragne:

julia> a = 2^60
1152921504606846976

julia> a:-a
1152921504606846976:1152921504606846975

julia> BigFloat(a):BigFloat(-a)
ERROR: ArgumentError: length cannot be negative, got -2305843009213693951
@mbauman
Copy link
Member

mbauman commented Apr 6, 2020

Duplicate of #10391

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants