Sebi B Sebi B -4 years ago 119
AngularJS Question

Math.ceil in angularjs returns wrong value

When I run

via console it returns
, which
also corresponds to the offical documentation.

But if I'm running
in my angularjs project, it
, which is actually not correct.

I wanted to seperate the digits between the comma, that's why I faced this problem.

Answer Source

I'm not too familiar with the internals of Angular's template code, but I believe it uses toString() on the variables that are to be displayed inside the template.

toString() is defined to return the string "0" if used on the Number type with value -0. You can try this out for yourself:


As @JamesThorpe mentioned in his comment, this behaviour is explicitly defined in the ECMA2015 standard. Quoting the document: ToString Applied to the Number Type

The abstract operation ToString converts a Number m to String format as follows:


  1. If m is +0 or −0, return the String "0".
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download