(int) no funciona?
Frecuentes
Visto 165 equipos
1
I want to convert double value of 1.09478878083135368E7 to int. so I use
int formatted = (int)1.09478878083135368E7;
Then I send this value to another activity as a string by using
final string distance = String.valueOf(formatted);
I'm expecting to see "1" as a result but what I'm getting is 10947878. Any idea?
1 Respuestas
6
1.09478878083135368E7
.. Notice the E7, that's (científica) notación E for 'move the period E points right'.
Así que en tu caso; 1.09478878083135368E7
se convierte en 10947887.8083135368
, so converting to an int gives us 10947887 (you have 10947878 which might have been a typo?)
Respondido 12 Feb 14, 07:02
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas android type-conversion or haz tu propia pregunta.
to add, if you want the integer value, user
Math.round
- elpooshwhy ? using Math.round also get 10947878 - PascuaKim
Math.Round
might actually get you +1 in this case because of the.8
; so the number on aMath.Round
sería10947888
(maybe not what you want in this case?) - txtechhelpthanks a lot textechhelp and thepoosh . I finally use Math.round :) - PascuaKim