css - Less percentage not work right -


I am trying to get percent in the less CSS file with accuracy of 2 digits. I am in less CSS file

  @w: round ((100 - ((12-5) * 3.8)) / (12/5)) * 100); Width: percent (@ w / 10000);   

Compiled in width: 30.58 billion to 20000002%; What am i doing wrong

My reasoning is very simple:
Step 1: Get the number 30.580000000000002 - "Step 2": 30.580000000000002 * 100 = 3058.0000000000002 # Step 3: Round (3058.0000000000002) = 3058 - Phase 4: 3058/10000 = 0.3058 - Step 5: Percent (0.3058) = 30.58

Do not you think The floating point computation is done in binary, where there is no true representation of 1/10000 therefore:

  / * 30.58000000000000002 * / console.log (Math ((((100 (( 12 - 5) * 3.8)) / (12/5)) * 100) / 10000 * 100);   

(Unless Javascript uses an ECMAScript implementation as well, it does not matter unless the calculation is based on double-specific floating-point numbers.) < / P>

However, you should not bother about it. Width: 30.580000000000002%;



Comments