Skip to content

Ranges with Rational elements #1

@mcabbott

Description

@mcabbott

Ranges with eltype Rational work OK in base 2

julia> onetwo(1//8, 8)
7-element OneTwoFive.Struct{Rational{Int64}, 2, 1}:
 1//8, 1//4, 1//2, 1//1, 2//1, 4//1, 8//1

... but are quite ugly in base 10:

julia> x10 = onetwofive(1//10, 10) 
7-element OneTwoFive.Struct{Rational{Int64}, 10, 3}:
 3602879701896397//36028797018963968  1//2, 1//1, 2//1, 5//1, 10//1

julia> dump(x10)
OneTwoFive.Struct{Rational{Int64}, 10, 3}
  off: Int64 -3
  len: Int64 7

julia> float(x10)
7-element OneTwoFive.Struct{Float64, 10, 3}:
 0.1, 0.2, 0.5, 1.0, 2.0, 5.0, 10.0

julia> x10 .+ 0.0
7-element Vector{Float64}:
  0.1
  0.2
  0.5
  1.0
  2.0
  5.0
 10.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions