V
V
Vyacheslav2016-04-21 00:29:21
Java
Vyacheslav, 2016-04-21 00:29:21

Why do we get such output to the console when executing this code?

Why do we get zero with a minus sign when we multiply a negative double or float number by zero?
double x = -1;
x *= 0;
System.out.print(x);
stdout
-0.0
float x = -1f;
x *= 0;
System.out.print(x);
stdout
-0.0

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Saboteur, 2016-04-21
@brod2855

Java stores numbers according to the https://ru.wikipedia.org/wiki/IEEE_754-2008
standard , in which all numbers, including zero, can be positive or negative.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question