# Customize a floating type to display different precisions

**URL:** <https://discourse.julialang.org/t/customize-a-floating-type-to-display-different-precisions/54510>\
**Category:** General Usage\
**Tags:** question\
**Created:** [February 3, 2021, 3:30am UTC](https://discourse.julialang.org/t/customize-a-floating-type-to-display-different-precisions/54510 "2021-02-03T03:30:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zq\_F](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zq_f/32/20147_2.png) [@Zq\_F](https://discourse.julialang.org/u/Zq_F)\
**Post date:** [February 3, 2021, 3:30am UTC](https://discourse.julialang.org/t/customize-a-floating-type-to-display-different-precisions/54510/1 "2021-02-03T03:30:59Z")

</div>

Customize a floating type to display different precisions

Hello, everyone  
I want to customize a floating type to display three decimal places, such as displaying 3.141

I have used the following sentence before  
show(io::IO, e::Float32) = print(io, @sprintf(“%.2f”, e))

So the following has warning  
const ff33 = Float32  
show(io::IO, e::ff33) = print(io, @sprintf(“%.3f”, e))

primitive type ff33 \<: AbstractFloat 32 end  
This definition is ok, but the type conversion of ff33 and Float32 has to be processed

Is there the easiest way to customize the display of three decimal places?

Can someone help me with this?

---

<div class="post-metadata">

**Author:** ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Post date:** [February 3, 2021, 7:27am UTC](https://discourse.julialang.org/t/customize-a-floating-type-to-display-different-precisions/54510/2 "2021-02-03T07:27:09Z")

</div>

Try

```julia
julia> round(pi, sigdigits=3)
3.14

```

---

<div class="post-metadata">

**Author:** ![Zq\_F](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zq_f/32/20147_2.png) [@Zq\_F](https://discourse.julialang.org/u/Zq_F)\
**Post date:** [February 3, 2021, 8:11am UTC](https://discourse.julialang.org/t/customize-a-floating-type-to-display-different-precisions/54510/3 "2021-02-03T08:11:45Z")

</div>

Thank you  
But I don’t want to change the value of the data, just want to display different decimal places

---

<div class="post-metadata">

**Author:** ![liuyxpp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/liuyxpp/32/9870_2.png) [@liuyxpp](https://discourse.julialang.org/u/liuyxpp)\
**Post date:** [February 3, 2021, 8:15am UTC](https://discourse.julialang.org/t/customize-a-floating-type-to-display-different-precisions/54510/4 "2021-02-03T08:15:19Z")

</div>

As suggested by @dpsanders, just do a `round` before each display of your number.
