After a calculation I got 32.073 .I need it to round to 32.07 using Octave.Please can somebody help me?
For display purposes, use sprintf to control the exact display of a number as a string. For example, to display exactly 2 decimal digits of pi (and no trailing zeros), use sprintf("%. 2f",pi) .
The output_precision command is what you want. Setting format long provides much more than the requested amount of precision. That may be okay, but if you want a specific precision, use output_precision instead.
Select MATLAB > Command Window, and then choose a Numeric format option. The following table summarizes the numeric output format options. Short, fixed-decimal format with 4 digits after the decimal point.
You can do:
res = round(100 * 37.073) / 100
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With