Skip to content

log option of operator_mathof should use log10 #2563

@apple502j

Description

@apple502j

Expected Behavior

log block should use log10 instead of log + dividing by LN10

Actual Behavior

log block does not use log10, which can lead to precision issues that can be solved easily - e.g. log of 1000 is not 3

Source Code

https://github.com/LLK/scratch-vm/blob/develop/src/blocks/scratch3_operators.js#L146

This should be changed to

        case 'log': return Math.log10(n);

Math.log10 should be available on all supported browsers.

Performance test?

log10 is 2x faster.
image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions