Skip to content

Round up returns wrong number  #218

Open
@takihama

Description

I'm expecting the result of the roundUp to be 1.12, but it returns wrongly 1.13.

const Big = require('big.js');

const amountAvailable = 1.12;
const quantityArs = 1197.5384615384617;
const exchangeRate = 1069.2307692307693;

// Big
console.log(Big(amountAvailable).times(exchangeRate).toNumber()); // 1197.5376
console.log(Big(quantityArs).div(exchangeRate).toNumber()); // 1.12
console.log(Big(quantityArs).div(exchangeRate).round(2, Big.roundUp).toNumber()); // 1.13
console.log(Big(1.12).round(2, Big.roundUp).toNumber()); // 1.12

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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