# Rounding off a number to 5 decimal digits

17 views (last 30 days)
Mantej Sokhi on 19 Sep 2022
Commented: Image Analyst on 19 Sep 2022
Suppose I have a number .. let's say x = 1.4534567809385. If I want to round this off to 5 decimal digits I should get x = 1.45346. However when I try doing this in Matlab using the round function or creating my own function to round it off to 5 decimal digits I am always getting 4 decimal digits. How can I fix this ?
##### 0 CommentsShowHide -1 older comments

Sign in to comment.

### Accepted Answer

Image Analyst on 19 Sep 2022
It's just displaying 4 places because you're using format short. Switch to format long and you'll see it correctly.
x = 1.4534567809385;
x5 = round(x, 5)
x5 = 1.4535
format long
x = 1.4534567809385;
x5 = round(x, 5)
x5 =
1.453460000000000
##### 2 CommentsShowHide 1 older comment
Image Analyst on 19 Sep 2022

Sign in to comment.

### Categories

Find more on Logical 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!

Translated by