Javascript parseInt returning fractional number?

Hey ! I’m geting an element’s width using this method:

var containerWidth = parseInt($(".progress-bar").width());

So I can do this:

if(barWidth >= (containerWidth*60)/100){
  do something...
}

I’m trying to see if the child element’s width corresponds to 60% of the parent’s width, since I could’t find a method that returns the width in percentages. The problem is that the fractional part of the result of this expression (containerWidth*60)/100 returned by javascript and my calculator wasn’t equal, so I decided to convert it to Interger but it just returned a smaller fractional number.

Can you post the example numbers?

The element’s width is 157.688, the expression on my cellphone calculator returned 94.6128 while javascript returned 94.6125. When I parsed the value it returned 94.2

1 Like

Stupid computers…

2 Likes