# Floor? Force magnitude amount?

**URL:** <https://discourse.julialang.org/t/floor-force-magnitude-amount/88833>\
**Category:** General Usage\
**Created:** [October 17, 2022, 8:39am UTC](https://discourse.julialang.org/t/floor-force-magnitude-amount/88833 "2022-10-17T08:39:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![theboiwholived](https://avatars.discourse-cdn.com/v4/letter/t/aeb1de/32.png) [@theboiwholived](https://discourse.julialang.org/u/theboiwholived)\
**Post date:** [October 17, 2022, 8:39am UTC](https://discourse.julialang.org/t/floor-force-magnitude-amount/88833/1 "2022-10-17T08:39:34Z")

</div>

Hey all,

Newer to julia and working with some very large numbers. Unfort conditioning of the system im using leads to numerical issues with numbers spanning more than 12 orders of magnitude.

I’ve been working in bigInt and trying things like Float64(quantity\*1e-10, RoundDown)  
But my numbers can go anywhere from 1e24, 1e12 1e7, 1ewhatever anything really and majority over 12. So theres gotta be a way to just force numbers to be no more than 1e12 or 1e#, like a floor or round im not to sure the best way.

Really grateful for you julia pros! Cheers! 🙂

---

<div class="post-metadata">

**Author:** ![jar1](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@jar1](https://discourse.julialang.org/u/jar1)\
**Post date:** [October 17, 2022, 8:56am UTC](https://discourse.julialang.org/t/floor-force-magnitude-amount/88833/2 "2022-10-17T08:56:01Z")

</div>

How about `min(x, 1e12)`?

---

<div class="post-metadata">

**Author:** ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)\
**Post date:** [October 17, 2022, 9:20am UTC](https://discourse.julialang.org/t/floor-force-magnitude-amount/88833/3 "2022-10-17T09:20:15Z")

</div>

I’m unclear on the specification but for some interpretation, `exp10(floor(log10(x)))` might be an option.

---

<div class="post-metadata">

**Author:** ![digital\_carver](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/digital_carver/32/33818_2.png) [@digital\_carver](https://discourse.julialang.org/u/digital_carver)\
**Post date:** [October 17, 2022, 2:09pm UTC](https://discourse.julialang.org/t/floor-force-magnitude-amount/88833/4 "2022-10-17T14:09:43Z")

</div>

I’m not sure about the specification either, but in case you want the values to be limited to a maximum value, `clamp` is worth a look.

```julia
julia> clamp.([1e24, 1e13, 1e12, 1e7], floatmin(), 1e12)
4-element Vector{Float64}:
 1.0e12
 1.0e12
 1.0e12
 1.0e7

```

---

<div class="post-metadata">

**Author:** ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)\
**Post date:** [October 17, 2022, 2:36pm UTC](https://discourse.julialang.org/t/floor-force-magnitude-amount/88833/5 "2022-10-17T14:36:22Z")

</div>

A single-sided `clamp` is just a `min` or a `max`. In this case `min.([1e24, 1e13, 1e12, 1e7], 1e12)` gives the same result.

---

<div class="post-metadata">

**Author:** ![theboiwholived](https://avatars.discourse-cdn.com/v4/letter/t/aeb1de/32.png) [@theboiwholived](https://discourse.julialang.org/u/theboiwholived)\
**Post date:** [October 18, 2022, 6:44pm UTC](https://discourse.julialang.org/t/floor-force-magnitude-amount/88833/6 "2022-10-18T18:44:17Z")

</div>

thanks so much guys 😃
