Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4826

Helper is doing something weird to integer arguments

$
0
0

The context is that I’m trying to create a helper that converts bytes into human-readable file sizes. It accepts a single argument- a number of bytes.

I’ve noticed that certain numbers become different or undefined by the time they’re used in the helper. What would be causing this?

Correct

{{my-helper 2345234534}} //console.log(params[0]) => 2345234534
{{my-helper 2230000000}} //console.log(params[0]) => 2230000000
{{my-helper 200000000}}  //console.log(params[0]) => 200000000

Incorrect

{{my-helper 1230000001}} //console.log(params[0]) => 156258177
{{my-helper 1230000000}} //console.log(params[0]) => 156258176
{{my-helper 1999999999}} //console.log(params[0]) => undefined
{{my-helper 1000000000}} //console.log(params[0]) => undefined
{{my-helper 2000000000}} //console.log(params[0]) => undefined

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 4826

Trending Articles