0

I have ng-repeat on a table row <tr> in which a td are filled out by ng-repeat. one of the <td> i have to make a simple calculation like that:

 <td>{{ (total.drawerAmount + total.totalReturns ) - total.totalWithd }}</td>

this returns 0.0005000000019208528 while it should return 0, meanwhile it works fine when i make it in this form:

<td>{{ total.drawerAmount + total.totalReturn }}</td>

please can someone explain why it works when i only put two variable and it go wrong when i put three variable in the calculation? Thanks in advance

sabithpocker
  • 15,274
  • 1
  • 42
  • 75
Ali
  • 1,633
  • 7
  • 35
  • 58
  • try without the brackets (). + and - will result in the same number with or without brackets. – st_stefanov May 16 '18 at 17:28
  • same result even when i removed the brackets – Ali May 16 '18 at 17:30
  • 1
    Ok, sure, that is one step. Next put simple number in the {{ }}, like this {{ 5+ 7 - 2}} and see the result. I bet it calculates fine. This will lead you to the conclusion that the variables values are not Ok. – st_stefanov May 16 '18 at 17:33
  • What are the numeric values of each of your variables? – Rani Radcliff May 16 '18 at 17:51
  • @RaniRadcliff i tried new values and they are exactly : `{9900 + 1000 - 1000 } , the result is `8900.0001` – Ali May 16 '18 at 21:12
  • i solved the problem by removing the quotations from the json around them, it was making errors because the browser was reading them as strings maybe? – Ali May 16 '18 at 21:30

0 Answers0