0

How do i convert a negative number into positive even though i applied Math.abs(days) but it doesn't work ?

Java Swing netbeans

28th Apr 2019, 6:14 AM
Daryll Culas
Daryll Culas - avatar
4 Respuestas
+ 11
Please add a minimal working example on the playground and link it to your question. That will increase the chances to receive helpful answers.
28th Apr 2019, 6:24 AM
Tashi N
Tashi N - avatar
+ 4
days = days < 0 ? -days : days;
28th Apr 2019, 8:30 AM
Anna
Anna - avatar
+ 2
Math.abs() returns a double. If you are using int days --> days = (int)Math.abs(days);
28th Apr 2019, 5:13 PM
Denise Roßberg
Denise Roßberg - avatar
+ 1
Can you provide us the code because Mat.abs is the best way to do that
28th Apr 2019, 6:24 AM
Seniru
Seniru - avatar