nicolaspanel / numjs

Like NumPy, in JavaScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

numjs.round acts not same with numpy.round

tearsofphoenix opened this issue · comments

According to numpy document:

The result of rounding a float is a float. For values exactly halfway between rounded decimal 
values, NumPy rounds to the nearest even value. Thus 1.5 and 2.5 round to 2.0, -0.5 and 0.5 
round to 0.0, etc.

but numjs.round to the nearest value. I have test:

const x = numjs.array([1.5, 2.5, -0.5, -1, 100])
console.log(nj.round(x).tolist())

got result:

[ 2, 3, -0, -1, 100 ]

Would this be fixed to floor?