0

Whene int a =2.3 ; I need to stor (a) as 3

How

3rd Jan 2021, 11:28 PM
badreldeen ebraheem
badreldeen ebraheem - avatar
3 ответов
+ 5
badreldeen ebraheem In Java integer can't store double value. So int a = 2.3 will be wrong it would be double a = 2.3; if you want 3 then you have to use Math.ceil() then typecast with int like int b = (int) Math.ceil(a);
4th Jan 2021, 3:34 AM
A͢J
A͢J - avatar
+ 2
I will assume you are using Python First of all, you need to input a float, not int. Play with this snippet: num = float(input() or 2.3) num = str(num).split('.') print(int(num[1]))
4th Jan 2021, 1:52 AM
Rik Wittkopp
Rik Wittkopp - avatar
0
Thanks 😊 I am use java. In sololearn l have a problem (loan calculator) I actually did what you said But given me an error I don't know why
4th Jan 2021, 12:25 PM
badreldeen ebraheem
badreldeen ebraheem - avatar