# \#rounding

**URL:** https://discourse.julialang.org/tag/rounding/706.md

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

---

## [Improve performance of this index creation and accessing code](https://discourse.julialang.org/t/improve-performance-of-this-index-creation-and-accessing-code/134235)

<div class="topic-metadata">

**Author:** [@raman\_kumar](https://discourse.julialang.org/u/raman_kumar)\
**Replies:** 65\
**Last updated:** [January 30, 2026, 3:47pm UTC](https://discourse.julialang.org/t/improve-performance-of-this-index-creation-and-accessing-code/134235 "2026-01-30T15:47:32Z")

</div>

How to improve the performance of clp(j) function given below. Please suggest faster version of this code. I am converting spherical coordinates to Cartesian and placing color values to exact location in data. Otherwise…

---

## [Numerical accuracy/machine accuracy and roundness in Julia](https://discourse.julialang.org/t/numerical-accuracy-machine-accuracy-and-roundness-in-julia/124541)

<div class="topic-metadata">

**Author:** [@Ofenblech](https://discourse.julialang.org/u/Ofenblech)\
**Replies:** 12\
**Last updated:** [January 9, 2025, 10:26am UTC](https://discourse.julialang.org/t/numerical-accuracy-machine-accuracy-and-roundness-in-julia/124541 "2025-01-09T10:26:50Z")

</div>

Dear community, I am new to the forum and I’m looking for a good option for how I can round Julia’s machine accuracy for polynomials or simplify the numbers in the system. I am concerned with the following problems: I …

---

## [Should InexactError be thrown when converting from Int64 to Float64?](https://discourse.julialang.org/t/should-inexacterror-be-thrown-when-converting-from-int64-to-float64/124531)

<div class="topic-metadata">

**Author:** [@xor0110](https://discourse.julialang.org/u/xor0110)\
**Replies:** 4\
**Last updated:** [January 9, 2025, 7:13am UTC](https://discourse.julialang.org/t/should-inexacterror-be-thrown-when-converting-from-int64-to-float64/124531 "2025-01-09T07:13:57Z")

</div>

Converting from Float64 to Int64 works fine if the number is an integer, otherwise a InexactError is thrown, and the user is required to use a function such as round or floor to perform the conversion in general. julia\> …

---

## [What interface to implement for \`round(x, digits=n)\` to work?](https://discourse.julialang.org/t/what-interface-to-implement-for-round-x-digits-n-to-work/122372)

<div class="topic-metadata">

**Author:** [@barucden](https://discourse.julialang.org/u/barucden)\
**Replies:** 2\
**Last updated:** [November 7, 2024, 9:32am UTC](https://discourse.julialang.org/t/what-interface-to-implement-for-round-x-digits-n-to-work/122372 "2024-11-07T09:32:38Z")

</div>

There is a section in the documentation that explains what methods to implement to support rounding on a new type: Apparently, one needs to implement round(x::ObjType, r::RoundingMode). The section even includes an exa…

---

## [How can I round the elements of an array to have digits up to the order of magnitude of the last significant digit in a second array](https://discourse.julialang.org/t/how-can-i-round-the-elements-of-an-array-to-have-digits-up-to-the-order-of-magnitude-of-the-last-significant-digit-in-a-second-array/117378)

<div class="topic-metadata">

**Author:** [@Zotnam](https://discourse.julialang.org/u/Zotnam)\
**Replies:** 13\
**Last updated:** [July 24, 2024, 3:16pm UTC](https://discourse.julialang.org/t/how-can-i-round-the-elements-of-an-array-to-have-digits-up-to-the-order-of-magnitude-of-the-last-significant-digit-in-a-second-array/117378 "2024-07-24T15:16:34Z")

</div>

Hi, i have two arrays of float64: arr\_mean and arr\_stds. i can easily round arr\_stds to 1 or 2 significative digits with round.(arr\_stds, sigdigits=2). My problem is how to round arr\_mean so that each elements after…

---

## [Issue with BigFloat rounding](https://discourse.julialang.org/t/issue-with-bigfloat-rounding/116831)

<div class="topic-metadata">

**Author:** [@chkat](https://discourse.julialang.org/u/chkat)\
**Replies:** 14\
**Last updated:** [July 10, 2024, 3:09pm UTC](https://discourse.julialang.org/t/issue-with-bigfloat-rounding/116831 "2024-07-10T15:09:01Z")

</div>

I want to set the BigFloat(7.0687866210937500e-1) by using a precision of 15 bits and two different rounding modes (up and down). So I do: setprecision(15) setrounding(BigFloat, RoundDown) # or RoundUp BigFloat(7.0687…

---

## [How do I restrict the number of digits in the REPL display?](https://discourse.julialang.org/t/how-do-i-restrict-the-number-of-digits-in-the-repl-display/107501)

<div class="topic-metadata">

**Author:** [@chandra](https://discourse.julialang.org/u/chandra)\
**Replies:** 9\
**Last updated:** [December 15, 2023, 3:30am UTC](https://discourse.julialang.org/t/how-do-i-restrict-the-number-of-digits-in-the-repl-display/107501 "2023-12-15T03:30:26Z")

</div>

I wish to restrict the number of significant digits displayed on the REPL according to a context-dependent format like format in MATLAB or Octave. I have looked through the documentation, but have not seen what I am lo…

---

## [\[ANN\] CircuitComponentRounding.jl](https://discourse.julialang.org/t/ann-circuitcomponentrounding-jl/62496)

<div class="topic-metadata">

**Author:** [@TheLateKronos](https://discourse.julialang.org/u/TheLateKronos)\
**Replies:** 1\
**Last updated:** [May 17, 2023, 8:42am UTC](https://discourse.julialang.org/t/ann-circuitcomponentrounding-jl/62496 "2023-05-17T08:42:35Z")

</div>

I am pleased to announce CircuitComponentRounding.jl, a Julia package for rounding a set of e.g. calculated values to their nearest standardized values, which will actually exist in normal component storages! The followi…

---

## [Rounding solution output in JuMP](https://discourse.julialang.org/t/rounding-solution-output-in-jump/96786)

<div class="topic-metadata">

**Author:** [@samerb](https://discourse.julialang.org/u/samerb)\
**Replies:** 5\
**Last updated:** [March 29, 2023, 7:32pm UTC](https://discourse.julialang.org/t/rounding-solution-output-in-jump/96786 "2023-03-29T19:32:55Z")

</div>

When I solve a problem in JuMP, my code ends with optimize!(model); @show value(m); end and then it prints the solution m to the problem–as directed by the @show value(m) line. But it prints many decimal places of m…

---

## [Round Dates.Time variable](https://discourse.julialang.org/t/round-dates-time-variable/88306)

<div class="topic-metadata">

**Author:** [@fipelle](https://discourse.julialang.org/u/fipelle)\
**Replies:** 7\
**Last updated:** [October 6, 2022, 5:46pm UTC](https://discourse.julialang.org/t/round-dates-time-variable/88306 "2022-10-06T17:46:43Z")

</div>

Hi, I am trying to round two variables - say X and Y - of type Dates.Time. X has value 09:30:01.017, Y has value 09:59:59.103 and I would like to round them to 09:30:00.000 and 10:00:00.000. I have tried using floor and…

---

## [Arithmetic with a specified (low) number of digits](https://discourse.julialang.org/t/arithmetic-with-a-specified-low-number-of-digits/86713)

<div class="topic-metadata">

**Author:** [@DanielVandH](https://discourse.julialang.org/u/DanielVandH)\
**Replies:** 1\
**Last updated:** [September 3, 2022, 1:12am UTC](https://discourse.julialang.org/t/arithmetic-with-a-specified-low-number-of-digits/86713 "2022-09-03T01:12:22Z")

</div>

Is it possible to perform computations using, say, five-digit arithmetic with a given rounding mode? For example, can I easily compute x/10^{-5}, x = 0.44446, in 5-digit arithmetic with rounding to the nearest number? I …

---

## [How to round whole matrix like numpy.round()](https://discourse.julialang.org/t/how-to-round-whole-matrix-like-numpy-round/84897)

<div class="topic-metadata">

**Author:** [@Starpower\_Power](https://discourse.julialang.org/u/Starpower_Power)\
**Replies:** 8\
**Last updated:** [July 29, 2022, 12:13pm UTC](https://discourse.julialang.org/t/how-to-round-whole-matrix-like-numpy-round/84897 "2022-07-29T12:13:42Z")

</div>

how to round whole matrix like numpy.round() how to round SymPy Matrix in julia SymPy pakage

---

## [Why assuming floating-point rounding errors are random is bad](https://discourse.julialang.org/t/why-assuming-floating-point-rounding-errors-are-random-is-bad/70647)

<div class="topic-metadata">

**Author:** [@ettersi](https://discourse.julialang.org/u/ettersi)\
**Replies:** 14\
**Last updated:** [April 22, 2022, 11:46am UTC](https://discourse.julialang.org/t/why-assuming-floating-point-rounding-errors-are-random-is-bad/70647 "2022-04-22T11:46:05Z")

</div>

This topic continues a discussion started in another topic here on discourse. The goal here is to assemble a list of potential issues which may arise if you assume floating-point rounding errors are random rather than d…

---

## [Round vector Float64](https://discourse.julialang.org/t/round-vector-float64/71413)

<div class="topic-metadata">

**Author:** [@Sbeltranj](https://discourse.julialang.org/u/Sbeltranj)\
**Replies:** 1\
**Last updated:** [November 13, 2021, 12:13am UTC](https://discourse.julialang.org/t/round-vector-float64/71413 "2021-11-13T00:13:15Z")

</div>

Hi I want to round a vector, I want each element to round 0.1. how I do this?
