Skip to content

map() truncation of integral results is confusing. [imported] #288

Closed
@cmaglie

Description

@cmaglie

This is Issue 288 moved from a Google Code project.
Added by 2010-07-11T21:22:11.000Z by dmel...@gmail.com.
Please review that bug for more context and additional comments, but update this bug.

Original labels: Type-Defect, Priority-Medium, Component-Core

Original description

For example, map(x, 0, 100, 0, 1) returns 0 for x from 0 to 99, whereas one might expect 50-100 to yield 1. This could be corrected by changing the function's calculation to:

(x - in_min) * (out_max - out_min + 1) / (in_max - in_min + 1) + out_min

Or by clarifying the behavior and usage in the documentation (e.g. explaining that you want to use the just past the range you're interested in).

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