How can I get the full value of a variable with decimal point
2 views (last 30 days)
Show older comments
r=77 g=65 b=41 factor=(g/b)/r; disp(factor);
the actual answer is 0.0205 But my result is displayed as 0 For 0.5 it is displayed as 1 How can I get the original value without roundoff please help me
0 Comments
Accepted Answer
Stephen23
on 14 Feb 2020
"the actual answer is 0.0205 But my result is displayed as 0 For 0.5 it is displayed as 1"
Those are the values, they are NOT just how they are displayed!
The problem is that your input values are integer (probably uint8), which means that the outputs are integer class too. You can check this easily yourself. The simple solution is to convert the input data to double before the division:
factor = (double(g)/double(b))/double(r)
More Answers (0)
See Also
Categories
Find more on Numeric Types in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!