I am developing a calculator for android
double
field Has been given the name result
, which I had inserted in a TextView
if I say result = 20.0
It should be presented as 20
(without the point and a zero). If results = 20.0001
it should be displayed unchanged.
Now I do with regular expressions but I think this is not a good idea. Is there another way of representing the double without any point and a zero if the double is actually an integer (without a point after the point)?
Use (d% 1 == 0) {
To check that your double is not a decimal part , then use intValue ()
integer
to get the double
method < / Code>
in 20.001 integer Can not be changed, decimal part can change to 20.0 integer, no decimal part is changed to 20.0 integer 20
No comments:
Post a Comment