Sum with decimals in browser.

1

Can someone help me understand, because the sum of 2 numbers in the 3 browsers (Chrome, iExplorer and Edge) alters the result?

In the image I display the examples that I tried. Some others give good, but those sought after at random, gives me incorrect values, which although they are not significant, according to me should not be ...

Also, if I add a number that starts at zero, it marks error ... That is strange, although that would be a lesser impact since values are normally used in variables.

You must have some reason! Does anyone know her? : |

    
asked by Omar Trinidad Chavez Mojarro 16.11.2017 в 20:42
source

2 answers

0

This is because you have a zero at the beginning of the numeric literal, as documentation

Yes the literal starts with a zero followed by another decimal number less than 8, it is interpreted as an octal number, that's why it shows the error. But there is the detail that if the number or numbers that follow after the 0 are outside the range 0-7 , zero is ignored at the beginning.

12.12 + 04.04  // error sigue 4 después del 0
12.12 + 09.04  // ignora el cero a la izquierda porque no está entre el rango 0-7

0122.3 +2    // error los números después del 0 están en el rango
0128.3 +2   // existe un número fuera del rango , se ignora el cero al inicio.
    
answered by 16.11.2017 / 21:56
source
0

It's because you have a 0 ahead of 4 . 04.04 and the number should be 4.04 , then making 12.12 + 4.04 should give you the result.

Is it for any reason in particular that you have that zero?

    
answered by 16.11.2017 в 21:43