Skip to content

Random float range: different behavior from CRuby #6720

Description

@bastienleonard

It seems that rand(range) with a float range doesn't have the same understanding of an inclusive range.

With current mruby master:

srand(0); 1000.times.map { rand(1.0..2.0) }.select { |n| n > 2.0 }.size
 => 492

With Ruby 4.0.1:

srand(0); 1000.times.map { rand(1.0..2.0) }.select { |n| n > 2.0 }.size
=> 0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions