0
How to calculate with a fractional number proceeded after 0?
I am trying to solve a problem and I know we can't divide or do any Arithmetic with anything that ceils to zero. Eg: 6/(23/45); or just show that number. Eg: 23/45; Now, if you build a calculator or other such code how will you overcome this? I tried this simple code: https://code.sololearn.com/cl5YfK0mS8RH/ any idea?
11 Respuestas
+ 2
It has no problem showing the number it has problem with doing Arithmetic operations with such number.
Eg: I tried double i = (10)/(23/45);
or i = 10 / 0.10;
And as always it gave an Exception in thread "main" java.lang.ArithmeticException: / by zero ;
I can't assure about other languages yet.
+ 2
I see even after casting into double the big operation is not resulting in right answers.
Got example in that code.
+ 1
I got the solution.
The problem was especially for fractional numbers after 0.
Solution:
Up cast or down cast.
on code playground, use try catch.
on netbeans it worked all the time even without try catch block.
0
after arithmetic calculations, how to show exact number, if you get the result such as 0.9
0
reply :
nop. If you look at the code, it shows double numbers in this formate : 0.0; that means not only int.
0
Also I tried Bing: showing correct answers.
Try this: ((3 / 9) * (8 / 10)) / (23 / 45) == 12 / 23
and you get this: ((3 / 9) * (8 / 10)) / (23 / 45) == 12 / 23 = True
How other things and calculators are calculating these?
0
so basically
if the ans is between 1 and 0
it shows as 0.0 right????
0
here is my solution
check.
https://code.sololearn.com/cJZ8EQ6f36pW/?ref=app
- 1
rifat
explain in details once more..
ehat exactly u want to do
- 1
i dont do java
but is there no thing to convert int from float..
looks like it prints the answer in int and so its always zero...
- 1
compiler varies then