# Round a float, and force a specific number of decimal places

**URL:** <https://discourse.julialang.org/t/round-a-float-and-force-a-specific-number-of-decimal-places/87547>\
**Category:** New to Julia\
**Tags:** numbers, formatting\
**Created:** [September 21, 2022, 7:22am UTC](https://discourse.julialang.org/t/round-a-float-and-force-a-specific-number-of-decimal-places/87547 "2022-09-21T07:22:15Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![albheim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/albheim/32/34660_2.png) [@albheim](https://discourse.julialang.org/u/albheim)\
**Post date:** [September 21, 2022, 7:41am UTC](https://discourse.julialang.org/t/round-a-float-and-force-a-specific-number-of-decimal-places/87547/2 "2022-09-21T07:41:32Z")

</div>

What is displayed and what it is rounded to is not the same thing, similar to your example we also have

```julia-repl
julia> round(10.1, sigdigits=2)
10.0

```

where it is correctly rounded to two significant digits, but since the following decimals are zero it is still displayed in standard float format with a single decimal zero to signify that it is a float with an integer value (I guess that is the reason at least).

So if you want to change the way that is shown as a result I guess you have to override the `show` method for floats.

If you just want to print it in a specific way you could have a look at `@printf`, see e.g.

> [@How to format float numbers in human-friendly format?](https://discourse.julialang.org/t/how-to-format-float-numbers-in-human-friendly-format/58209/2):
>
> I don’t know how “noisy” it is for you, but the command for versatile printing is [printf](https://docs.julialang.org/en/v1/stdlib/Printf/), which by the way is a lot faster than before in Julia 1.6 In this case, the command would be: @printf "my number: %.2f" f

---

_[View the full topic](https://discourse.julialang.org/t/round-a-float-and-force-a-specific-number-of-decimal-places/87547)._
