-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Open
Labels
rangesEverything AbstractRangeEverything AbstractRange
Description
range
calls Base._linspace
, which calls round
which is throwing an InexactError
for the following case:
start = 0.7071067811865475
len = 1449
range(start, nextfloat(start), len) # works
Base._linspace(start, nextfloat(start), len) # works
range(start, nextfloat(start), len + 1) # fails
Base._linspace(start, nextfloat(start), len + 1) # fails
The variable len
is shadowed inside _linspace
by one that is of type Int
or higher.
And the type of this len
is used by the round
function to determine what format to round to.
In my machine, Int
is Int64
. So round
tries to convert some large float to Int64
and fails.
This works:
range(start, nextfloat(start), Int128(len + 1))
Base._linspace(start, nextfloat(start), Int128(len + 1))
My hack right now is to define my own range function:
my_own_range_function(start, stop, len::Integer) = Base.range(start, stop, Int128(len))
I'm not sure hard-coding Int128
will handle all cases where round
throws an error.
related: #57113
Metadata
Metadata
Assignees
Labels
rangesEverything AbstractRangeEverything AbstractRange