Skip to content

Define behaviour with non-integer arguments #16

@parzhitsky

Description

@parzhitsky

Due to specifics ot IEEE 754 standard (see https://0.30000000000000004.com), it is not that straightforward to implement ranges with non-integer arguments.

xrange(1, 0, -0.1);
// expected:
// (10) [ 1, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1 ]
// actual:
// (11) [ 1, 0.9, 0.8, 0.7000000000000001, 0.6000000000000001, 0.5000000000000001, 0.40000000000000013, 0.30000000000000016, 0.20000000000000015, 0.10000000000000014, 1.3877787807814457e-16 ]

Perhaps, use https://github.com/MikeMcl/decimal.js (although, only a couple of methods from there are really needed)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Change: minor[Issue / PR] describes a non-breaking change, such as adding a new functionalityDomain: main[Issue / PR] describes change in the functionality, its optimizationPriority: high[Issue / PR] must be addressed as soon as possibleType: improvement[Issue / PR] addresses lack of a functionality or an open possibility of enhancementgood first issue[Issue] can be addressed by a first-time contributor

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions