Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rounding to two decimal places in Octave

After a calculation I got 32.073 .I need it to round to 32.07 using Octave.Please can somebody help me?

like image 574
AnoAPI Avatar asked Jul 11 '14 09:07

AnoAPI


People also ask

How do you round to 2 decimal places in Matlab?

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) .

How do you increase precision in octave?

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.

How do you change the number of decimal places in Matlab?

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.


1 Answers

You can do:

res = round(100 * 37.073) / 100
like image 131
Jean Logeart Avatar answered Oct 20 '22 17:10

Jean Logeart