# \#float

**URL:** https://discourse.julialang.org/tag/float/446.md

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

---

## [Why does base not include Float128?](https://discourse.julialang.org/t/why-does-base-not-include-float128/139092)

<div class="topic-metadata">

**Author:** [@rokke](https://discourse.julialang.org/u/rokke)\
**Replies:** 3\
**Last updated:** [August 29, 2026, 12:38am UTC](https://discourse.julialang.org/t/why-does-base-not-include-float128/139092 "2026-08-29T00:38:55Z")

</div>

I always thought it was weird that Base supports Float16 but doesn’t include Float128, even though IEE754 considers quads a basic format, while half is just an interchange format: the other benefit of including 128 in…

---

## [\[ANN\] PrecisionCarriers.jl: Easy Detection of Floating Point Precision Loss](https://discourse.julialang.org/t/ann-precisioncarriers-jl-easy-detection-of-floating-point-precision-loss/130670)

<div class="topic-metadata">

**Author:** [@AntonReinhard](https://discourse.julialang.org/u/AntonReinhard)\
**Replies:** 6\
**Last updated:** [February 6, 2026, 2:52pm UTC](https://discourse.julialang.org/t/ann-precisioncarriers-jl-easy-detection-of-floating-point-precision-loss/130670 "2026-02-06T14:52:08Z")

</div>

I recently registered a new package I’ve been working on: PrecisionCarriers.jl. It’s designed to let you check existing code very quickly and easily for loss of precision in its calculations. I added a macro inspired by…

---

## [Numeric stability of Base.exp of static matrix of Float32](https://discourse.julialang.org/t/numeric-stability-of-base-exp-of-static-matrix-of-float32/133389)

<div class="topic-metadata">

**Author:** [@Xu\_Shan](https://discourse.julialang.org/u/Xu_Shan)\
**Replies:** 12\
**Last updated:** [October 26, 2025, 7:46pm UTC](https://discourse.julialang.org/t/numeric-stability-of-base-exp-of-static-matrix-of-float32/133389 "2025-10-26T19:46:53Z")

</div>

Guys, I want to use Base.exp in my model which uses Float32 with StaticArray and StaticVector. However, I found there is a numerical instability of Base.exp with the 3\*3 matrix…see the example above: using StaticArrays…

---

## [Why does LLVM like putting floating-point constants into RODATA so much? Is that suboptimal?](https://discourse.julialang.org/t/why-does-llvm-like-putting-floating-point-constants-into-rodata-so-much-is-that-suboptimal/130314)

<div class="topic-metadata">

**Author:** [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Replies:** 1\
**Last updated:** [June 29, 2025, 8:36pm UTC](https://discourse.julialang.org/t/why-does-llvm-like-putting-floating-point-constants-into-rodata-so-much-is-that-suboptimal/130314 "2025-06-29T20:36:46Z")

</div>

It is almost impossible to avoid LLVM storing operands in floating-point operations into the data segment, RODATA, of the executable. For example, here the compiler converts 3 into Float64, storing the bytes into the da…

---

## [Default Real (Float) kind?](https://discourse.julialang.org/t/default-real-float-kind/129631)

<div class="topic-metadata">

**Author:** [@VinceNeede](https://discourse.julialang.org/u/VinceNeede)\
**Replies:** 50\
**Last updated:** [June 7, 2025, 8:47am UTC](https://discourse.julialang.org/t/default-real-float-kind/129631 "2025-06-07T08:47:43Z")

</div>

This is somehow a follow-up to this question: Disable promotion from Float64 to BigFloat The most used Fortran compilers offer the possibility to select which real kind should be used as default, i.e. the type (or bette…

---

## [Tracking a program and storing information in a data structure](https://discourse.julialang.org/t/tracking-a-program-and-storing-information-in-a-data-structure/129651)

<div class="topic-metadata">

**Author:** [@billyblueberry](https://discourse.julialang.org/u/billyblueberry)\
**Replies:** 0\
**Last updated:** [June 4, 2025, 6:06pm UTC](https://discourse.julialang.org/t/tracking-a-program-and-storing-information-in-a-data-structure/129651 "2025-06-04T18:06:50Z")

</div>

I am relatively new to Julia (\<1 year) and I am developing a tool for tracking floating point addition. I have set up my work as a package, here is a reduced MWE: module TestModule # used for storing information when a…

---

## [Why is my kernel as slow in FP32 as in FP64 on A2000 Ada-based GPU?](https://discourse.julialang.org/t/why-is-my-kernel-as-slow-in-fp32-as-in-fp64-on-a2000-ada-based-gpu/126809)

<div class="topic-metadata">

**Author:** [@Ludovic\_Dumoulin](https://discourse.julialang.org/u/Ludovic_Dumoulin)\
**Replies:** 10\
**Last updated:** [March 11, 2025, 2:39pm UTC](https://discourse.julialang.org/t/why-is-my-kernel-as-slow-in-fp32-as-in-fp64-on-a2000-ada-based-gpu/126809 "2025-03-11T14:39:58Z")

</div>

Hello, I am new to Julia and I wanted to use Float32 to debug my code expecting it be faster as my gpu provide only 1/64 of its performance in Float64. I was surprised to see that using Float32 was almost as slow as Fl…

---

## [How to Use Native FP4 and FP8 for Computation in the Julia Environment with CUDA.jl](https://discourse.julialang.org/t/how-to-use-native-fp4-and-fp8-for-computation-in-the-julia-environment-with-cuda-jl/125475)

<div class="topic-metadata">

**Author:** [@ajsagit](https://discourse.julialang.org/u/ajsagit)\
**Replies:** 0\
**Last updated:** [February 2, 2025, 3:15pm UTC](https://discourse.julialang.org/t/how-to-use-native-fp4-and-fp8-for-computation-in-the-julia-environment-with-cuda-jl/125475 "2025-02-02T15:15:47Z")

</div>

How to Use Native FP4 and FP8 for Computation in the Julia Environment with CUDA.jl TIA

---

## [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\> …

---

## [Kahan summation in \`sum\`?](https://discourse.julialang.org/t/kahan-summation-in-sum/102723)

<div class="topic-metadata">

**Author:** [@CameronBieganek](https://discourse.julialang.org/u/CameronBieganek)\
**Replies:** 13\
**Last updated:** [December 29, 2024, 1:04am UTC](https://discourse.julialang.org/t/kahan-summation-in-sum/102723 "2024-12-29T01:04:03Z")

</div>

I was under the impression that sum(itr) uses Kahan summation, but after inspecting the Julia repo it appears that it calls mapreduce(identity, add\_sum, itr). And add\_sum is basically just + with some promotions for smal…

---

## [Overflow issue?](https://discourse.julialang.org/t/overflow-issue/124009)

<div class="topic-metadata">

**Author:** [@Sahil\_Khan](https://discourse.julialang.org/u/Sahil_Khan)\
**Replies:** 3\
**Last updated:** [December 20, 2024, 4:40pm UTC](https://discourse.julialang.org/t/overflow-issue/124009 "2024-12-20T16:40:48Z")

</div>

Hello everyone, Is this a bug ? Why is it false for some specific numbers while true for others? julia\> 3 \* 1e-5 \* 1e5 == 3.0 false julia\> 5 \* 1e-5 \* 1e5 == 5.0 true julia\> 6 \* 1e-5 \* 1e5 == 6.0 false julia\> 7 \*…

---

## [How to Efficiently Work with Floats Across a Wide Range of Precision?](https://discourse.julialang.org/t/how-to-efficiently-work-with-floats-across-a-wide-range-of-precision/123833)

<div class="topic-metadata">

**Author:** [@Hugin-Hilbert](https://discourse.julialang.org/u/Hugin-Hilbert)\
**Replies:** 4\
**Last updated:** [December 16, 2024, 10:11am UTC](https://discourse.julialang.org/t/how-to-efficiently-work-with-floats-across-a-wide-range-of-precision/123833 "2024-12-16T10:11:20Z")

</div>

I’m currently developing a divide and conquer algorithm in Julia that requires multiple precision arithmetic at different levels of the computation: Leaf Nodes: Operations are performed with approximately 256-bit preci…

---

## [Get base10 mantissa and exponent of real (eg Float64)](https://discourse.julialang.org/t/get-base10-mantissa-and-exponent-of-real-eg-float64/121529)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 11\
**Last updated:** [October 22, 2024, 8:54am UTC](https://discourse.julialang.org/t/get-base10-mantissa-and-exponent-of-real-eg-float64/121529 "2024-10-22T08:54:36Z")

</div>

What would be the recommended way of getting the base 10 mantissa and exponent of a floating point number? Is there a package that does this? Or should I just reparse from printed representation, as in using Printf fu…

---

## [JSON.jl Float64 serialization (suppress scientific notation)](https://discourse.julialang.org/t/json-jl-float64-serialization-suppress-scientific-notation/119775)

<div class="topic-metadata">

**Author:** [@tamasgal](https://discourse.julialang.org/u/tamasgal)\
**Replies:** 0\
**Last updated:** [September 23, 2024, 9:04pm UTC](https://discourse.julialang.org/t/json-jl-float64-serialization-suppress-scientific-notation/119775 "2024-09-23T21:04:35Z")

</div>

I am having a hard time with JSON.jl. I want to serialize large Float64 instances without scientific notation and the only way I was able to get at least the rounding working results in a string, instead of a float value…

---

## [Compilers, purity, and variance computation](https://discourse.julialang.org/t/compilers-purity-and-variance-computation/119254)

<div class="topic-metadata">

**Author:** [@Palli](https://discourse.julialang.org/u/Palli)\
**Replies:** 5\
**Last updated:** [September 10, 2024, 6:35pm UTC](https://discourse.julialang.org/t/compilers-purity-and-variance-computation/119254 "2024-09-10T18:35:13Z")

</div>

MOST likely you call sum, then std, i.e. separate loops and scan twice, BUT technically the functional approach doesn’t rule out optimal performance: scanning just once… In theory the compiler (of functional languages a…

---

## [Dct error when using Images](https://discourse.julialang.org/t/dct-error-when-using-images/111775)

<div class="topic-metadata">

**Author:** [@AbdelazimHussien](https://discourse.julialang.org/u/AbdelazimHussien)\
**Replies:** 8\
**Last updated:** [August 26, 2024, 2:54am UTC](https://discourse.julialang.org/t/dct-error-when-using-images/111775 "2024-08-26T02:54:27Z")

</div>

Hello everyone, I have the following code using TestImages, ImageView img = testimage("cameraman") pixels = img\[1:8,1:8\] pixels = convert(Array{Float32}, pixels) freqs = dct(pixels) round(freqs) pixels2 = idct(freqs) b…

---

## [Roundoff error in variance of array of constant value](https://discourse.julialang.org/t/roundoff-error-in-variance-of-array-of-constant-value/116890)

<div class="topic-metadata">

**Author:** [@jgr](https://discourse.julialang.org/u/jgr)\
**Replies:** 7\
**Last updated:** [July 11, 2024, 10:31pm UTC](https://discourse.julialang.org/t/roundoff-error-in-variance-of-array-of-constant-value/116890 "2024-07-11T22:31:28Z")

</div>

In the code below, var(M) is not 0, I guess the reason might be computation error, but I wonder if anyone knows how to deal with this? Thanks in advance. M = fill(5.421241248937501521, (1,10000)) M = Float64.(M) var(M) …

---

## [Mismatch between nextfloat(0.0) and eps(Float64)](https://discourse.julialang.org/t/mismatch-between-nextfloat-0-0-and-eps-float64/115104)

<div class="topic-metadata">

**Author:** [@Guillermo\_C](https://discourse.julialang.org/u/Guillermo_C)\
**Replies:** 6\
**Last updated:** [June 3, 2024, 6:21pm UTC](https://discourse.julialang.org/t/mismatch-between-nextfloat-0-0-and-eps-float64/115104 "2024-06-03T18:21:14Z")

</div>

Dear Julia community, I am testing the representation of floating point values in my machine. This is the behavior I am seeing: julia\> x = 0.0 0.0 help?\> x (...) x is of type Float64 (...) julia\> nextfloat(x) 5.0e-324 …

---

## [Convert a tuple of matrix Float64 data to Float32](https://discourse.julialang.org/t/convert-a-tuple-of-matrix-float64-data-to-float32/112005)

<div class="topic-metadata">

**Author:** [@raman\_kumar](https://discourse.julialang.org/u/raman_kumar)\
**Replies:** 1\
**Last updated:** [March 23, 2024, 4:34am UTC](https://discourse.julialang.org/t/convert-a-tuple-of-matrix-float64-data-to-float32/112005 "2024-03-23T04:34:10Z")

</div>

I have a tuple of matrices data of type Float64 . But when i want to convert it to Float32 it gives error How to convert a tuple of matrix Float64 data to Float32 ?

---

## [Reinterpret byte to Float in julia](https://discourse.julialang.org/t/reinterpret-byte-to-float-in-julia/111670)

<div class="topic-metadata">

**Author:** [@raman\_kumar](https://discourse.julialang.org/u/raman_kumar)\
**Replies:** 4\
**Last updated:** [March 15, 2024, 4:54pm UTC](https://discourse.julialang.org/t/reinterpret-byte-to-float-in-julia/111670 "2024-03-15T16:54:21Z")

</div>

I have data of UInt8 type and i want to convert it into Float64. typeof(data) = Vector{UInt8} My data looks like :point\_right: data = read(f, N\_points \* 9) = UInt8\[0xdf, 0xfd, 0x5a, 0x80, 0x1c, 0x68, 0x86, 0x3f, 0xb6,…

---

## [Avogadro's number as a floating-point value](https://discourse.julialang.org/t/avogadros-number-as-a-floating-point-value/111379)

<div class="topic-metadata">

**Author:** [@foobar\_lv2](https://discourse.julialang.org/u/foobar_lv2)\
**Replies:** 18\
**Last updated:** [March 11, 2024, 2:10am UTC](https://discourse.julialang.org/t/avogadros-number-as-a-floating-point-value/111379 "2024-03-11T02:10:14Z")

</div>

Ok, on this topic: What on earth were the SI people thinking when they specced the current value of avogadro’s number? julia\> Int128(6.02214076e23) 602214075999999987023872 I get that they wanted to spec a nice round n…

---

## [I will never understand floating-point arithmetic](https://discourse.julialang.org/t/i-will-never-understand-floating-point-arithmetic/111342)

<div class="topic-metadata">

**Author:** [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Replies:** 17\
**Last updated:** [March 8, 2024, 4:05pm UTC](https://discourse.julialang.org/t/i-will-never-understand-floating-point-arithmetic/111342 "2024-03-08T16:05:15Z")

</div>

I will never understand float point arithmetic… julia\> a = 10000 \* 7 /100 700.0 julia\> b = 10000 \* 0.07 700.0000000000001 julia\> c = 1000 \* 0.69999999999999999 700.0 (but at list I am aware of the danger…)

---

## [Get length of a fully represented float](https://discourse.julialang.org/t/get-length-of-a-fully-represented-float/110521)

<div class="topic-metadata">

**Author:** [@HenriDeh](https://discourse.julialang.org/u/HenriDeh)\
**Replies:** 12\
**Last updated:** [February 21, 2024, 7:42pm UTC](https://discourse.julialang.org/t/get-length-of-a-fully-represented-float/110521 "2024-02-21T19:42:57Z")

</div>

Hello, I must work with a dataset of float numerical entries. A few of them (like 0.1%) are really small and thus are written in e-notation (e.g. 1.87589e-17). I’m passing this dataset to a C program via Julia and appar…

---

## [Int and float functions](https://discourse.julialang.org/t/int-and-float-functions/106770)

<div class="topic-metadata">

**Author:** [@fdekerme](https://discourse.julialang.org/u/fdekerme)\
**Replies:** 7\
**Last updated:** [November 27, 2023, 6:43am UTC](https://discourse.julialang.org/t/int-and-float-functions/106770 "2023-11-27T06:43:55Z")

</div>

Hello, Just a question: Why is the Int function capitalized and the float function lower-case? julia\> 0x0001 |\> Int 1 julia\> 0x0001 |\> float 1.0 julia\> 0x0001 |\> Float ERROR: UndefVarError: \`Float\` not defined Stackt…

---

## [Output distribution of rand(Float32) and rand(Float64), thread 2](https://discourse.julialang.org/t/output-distribution-of-rand-float32-and-rand-float64-thread-2/105184)

<div class="topic-metadata">

**Author:** [@foobar\_lv2](https://discourse.julialang.org/u/foobar_lv2)\
**Replies:** 437\
**Last updated:** [November 19, 2023, 12:45pm UTC](https://discourse.julialang.org/t/output-distribution-of-rand-float32-and-rand-float64-thread-2/105184 "2023-11-19T12:45:38Z")

</div>

A recent hackernews post lead me to necro https://discourse.julialang.org/t/output-distribution-of-rand/12192. If we want to reopen that can, I think a new thread is in order. Summary rand(), and much more acutely rand(…

---

## [Type-safe conversion of strings to numbers](https://discourse.julialang.org/t/type-safe-conversion-of-strings-to-numbers/105812)

<div class="topic-metadata">

**Author:** [@janonime](https://discourse.julialang.org/u/janonime)\
**Replies:** 7\
**Last updated:** [November 5, 2023, 10:00am UTC](https://discourse.julialang.org/t/type-safe-conversion-of-strings-to-numbers/105812 "2023-11-05T10:00:08Z")

</div>

It is easy to convert a string to a Float64: julia\> parse(Float64,"1.23456789") 1.23456789 It is (obviously) not possible to convert a string to an AbstractFloat: julia\> parse(AbstractFloat,"1.23456789") ERROR: Method…

---

## [Printing exact decimal representations](https://discourse.julialang.org/t/printing-exact-decimal-representations/103365)

<div class="topic-metadata">

**Author:** [@simonbyrne](https://discourse.julialang.org/u/simonbyrne)\
**Replies:** 2\
**Last updated:** [August 30, 2023, 12:06pm UTC](https://discourse.julialang.org/t/printing-exact-decimal-representations/103365 "2023-08-30T12:06:36Z")

</div>

I don’t think there is, but it would be great if there was one.

---

## [How to convert a number to an hexadecimal \`bitstring\`?](https://discourse.julialang.org/t/how-to-convert-a-number-to-an-hexadecimal-bitstring/98673)

<div class="topic-metadata">

**Author:** [@tokujin](https://discourse.julialang.org/u/tokujin)\
**Replies:** 3\
**Last updated:** [May 11, 2023, 11:27am UTC](https://discourse.julialang.org/t/how-to-convert-a-number-to-an-hexadecimal-bitstring/98673 "2023-05-11T11:27:11Z")

</div>

I can do string(parse(Int, bitstring(x), base=2), base=16) to convert bitstring(x) to an hexadecimal string, but is there another way, one which is simpler and doesn’t trim the leading zeros off of integers?

---

## [Weird floating point vs rational behavior](https://discourse.julialang.org/t/weird-floating-point-vs-rational-behavior/96466)

<div class="topic-metadata">

**Author:** [@DOT](https://discourse.julialang.org/u/DOT)\
**Replies:** 6\
**Last updated:** [March 23, 2023, 12:28pm UTC](https://discourse.julialang.org/t/weird-floating-point-vs-rational-behavior/96466 "2023-03-23T12:28:54Z")

</div>

Just when you think you’ve seen it all: Could someone please explain this to me? julia\> 10\*1.1 ≤ 11 true julia\> (10//1)\*1.1 ≤ (11//1) true julia\> (10//1)\*1.1 - (11//1) ≤ 0 true julia\> 1 ≤ (11//10)/1.1 true julia\> 1.…

---

## [Strange behavior of mod with float](https://discourse.julialang.org/t/strange-behavior-of-mod-with-float/93536)

<div class="topic-metadata">

**Author:** [@mleprovost](https://discourse.julialang.org/u/mleprovost)\
**Replies:** 3\
**Last updated:** [January 25, 2023, 10:52pm UTC](https://discourse.julialang.org/t/strange-behavior-of-mod-with-float/93536 "2023-01-25T22:52:12Z")

</div>

Hello, What is the best way to determine if a float number b is an integer multiple of another float number a, (i.e. b = k a with k an integer)? I wanted to use the following test abs(mod(b, a))\<1e-12, but I am confuse…

[Next page](https://discourse.julialang.org/tag/float/446.md?match_all_tags=true&page=1&tags%5B%5D=float)
