# \#unitful

**URL:** https://discourse.julialang.org/tag/unitful/618.md

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

---

## [\[ANN\] UnitfulGauss.jl, Gaussian EM units with proper gaussian physical dimensions](https://discourse.julialang.org/t/ann-unitfulgauss-jl-gaussian-em-units-with-proper-gaussian-physical-dimensions/138162)

<div class="topic-metadata">

**Author:** [@Gregstrq](https://discourse.julialang.org/u/Gregstrq)\
**Replies:** 0\
**Last updated:** [July 13, 2026, 5:43pm UTC](https://discourse.julialang.org/t/ann-unitfulgauss-jl-gaussian-em-units-with-proper-gaussian-physical-dimensions/138162 "2026-07-13T17:43:49Z")

</div>

I would like to announce UnitfulGauss.jl — a small extension package for Unitful.jl that defines Gaussian electromagnetic units with the proper Gaussian physical dimensions. Although Unitful.jl defines the Gaussian unit…

---

## [FlexUnits.jl The flexible units package](https://discourse.julialang.org/t/flexunits-jl-the-flexible-units-package/132528)

<div class="topic-metadata">

**Author:** [@Deduction42](https://discourse.julialang.org/u/Deduction42)\
**Replies:** 5\
**Last updated:** [May 12, 2026, 2:36pm UTC](https://discourse.julialang.org/t/flexunits-jl-the-flexible-units-package/132528 "2026-05-12T14:36:49Z")

</div>

FlexUnits.jl A units package that uses a very similar mechanism for unit tracking as DynamicQuantities.jl, but has an implementation that is more similar to Unitful.jl. The main difference comes from design decis…

---

## [Make Unitful simplify expressions like 1μm/1m to a unitless value by default](https://discourse.julialang.org/t/make-unitful-simplify-expressions-like-1-m-1m-to-a-unitless-value-by-default/71866)

<div class="topic-metadata">

**Author:** [@brianguenter](https://discourse.julialang.org/u/brianguenter)\
**Replies:** 10\
**Last updated:** [May 9, 2026, 1:10pm UTC](https://discourse.julialang.org/t/make-unitful-simplify-expressions-like-1-m-1m-to-a-unitless-value-by-default/71866 "2026-05-09T13:10:23Z")

</div>

I freguently perform computations like 1μm/1m and would like Unitful to return a unitless number by default rather than having to do NoUnits(1μm/1m). Is there a setting to make this the default?

---

## [\[ANN\] NaturallyUnitful.jl Natural Units for Physicists](https://discourse.julialang.org/t/ann-naturallyunitful-jl-natural-units-for-physicists/24456)

<div class="topic-metadata">

**Author:** [@Mason](https://discourse.julialang.org/u/Mason)\
**Replies:** 12\
**Last updated:** [April 1, 2026, 12:24pm UTC](https://discourse.julialang.org/t/ann-naturallyunitful-jl-natural-units-for-physicists/24456 "2026-04-01T12:24:33Z")

</div>

NaturallyUnitful.jl is a little package I made for conveniently switching to so called ‘natural units’ where one sets ħ = c = ϵ₀ = kb = 1. It’s built on top of the wonderful Unitful.jl and in fact re-exports it so that u…

---

## [Physical units in Julia](https://discourse.julialang.org/t/physical-units-in-julia/76825)

<div class="topic-metadata">

**Author:** [@tfiers](https://discourse.julialang.org/u/tfiers)\
**Replies:** 31\
**Last updated:** [March 1, 2026, 3:24am UTC](https://discourse.julialang.org/t/physical-units-in-julia/76825 "2026-03-01T03:24:37Z")

</div>

A big reason I came to Julia was to have physical units for scientific computations: g = 4 \* nS, E = 0 \* mV, input\_currents = g \* (E .- V\_mems). All of the current solutions in Python are unfeasibly slow if you use t…

---

## [Why do the density plots with Unitful display units on the "wrong" axis?](https://discourse.julialang.org/t/why-do-the-density-plots-with-unitful-display-units-on-the-wrong-axis/135727)

<div class="topic-metadata">

**Author:** [@bertulli](https://discourse.julialang.org/u/bertulli)\
**Replies:** 0\
**Last updated:** [February 19, 2026, 1:38pm UTC](https://discourse.julialang.org/t/why-do-the-density-plots-with-unitful-display-units-on-the-wrong-axis/135727 "2026-02-19T13:38:56Z")

</div>

Hi all! I noticed that, when plotting the probability distribution of some data with Plots.jl with density(x), the axis representing the “underlying” data, is on the x axis: using Plots using StatsPlots x = \[1,1,1,2,2\] …

---

## [Unitful.jl and DifferentialEquations.jl: compatibility?](https://discourse.julialang.org/t/unitful-jl-and-differentialequations-jl-compatibility/68594)

<div class="topic-metadata">

**Author:** [@Ickaser](https://discourse.julialang.org/u/Ickaser)\
**Replies:** 16\
**Last updated:** [February 13, 2026, 11:56pm UTC](https://discourse.julialang.org/t/unitful-jl-and-differentialequations-jl-compatibility/68594 "2026-02-13T23:56:04Z")

</div>

I’ve been using Julia for a little while, long enough to have successfully solved ODEs before. I’m trying to use DifferentialEquations together with Unitful, which I thought I had read should work, but it doesn’t seem to…

---

## [How to create a DataFrame from code literals, especially with Unitful?](https://discourse.julialang.org/t/how-to-create-a-dataframe-from-code-literals-especially-with-unitful/135613)

<div class="topic-metadata">

**Author:** [@bertulli](https://discourse.julialang.org/u/bertulli)\
**Replies:** 8\
**Last updated:** [February 13, 2026, 6:35pm UTC](https://discourse.julialang.org/t/how-to-create-a-dataframe-from-code-literals-especially-with-unitful/135613 "2026-02-13T18:35:45Z")

</div>

Hi all! I’m working with some physical quantities and I’d like to use Unitful.jl for that. I am wondering two things: what is the most easily maintainable, and/or efficient way to crate a DataFrame from code literals (…

---

## [Numerical sensitivity of eigvecs for \`≈\` identical (unitful) matrices?](https://discourse.julialang.org/t/numerical-sensitivity-of-eigvecs-for-identical-unitful-matrices/134846)

<div class="topic-metadata">

**Author:** [@bremez](https://discourse.julialang.org/u/bremez)\
**Replies:** 3\
**Last updated:** [January 3, 2026, 2:11am UTC](https://discourse.julialang.org/t/numerical-sensitivity-of-eigvecs-for-identical-unitful-matrices/134846 "2026-01-03T02:11:09Z")

</div>

I came across the following discrepancy, see MWE: using LinearAlgebra, Unitful GHz = 1u"GHz"; wq = 6.7565\*GHz; wc = 20\*GHz; g = 0.1847\*GHz; Ns = 10; op = diagm(1 =\> sqrt.(1:Ns)); b = kron(op, I(Ns+1)); a = kron(I(Ns+1),…

---

## [Dispatch on specific Unitful unit](https://discourse.julialang.org/t/dispatch-on-specific-unitful-unit/124774)

<div class="topic-metadata">

**Author:** [@Nathan\_Boyer](https://discourse.julialang.org/u/Nathan_Boyer)\
**Replies:** 7\
**Last updated:** [July 11, 2025, 1:32pm UTC](https://discourse.julialang.org/t/dispatch-on-specific-unitful-unit/124774 "2025-07-11T13:32:11Z")

</div>

Continuing the discussion from Unitful dispatch: I want to dispatch specifically on u"inch". What am I missing? In this MWE, I want mm(1), mm(1u"inch"), and mm(1.0u"inch") to all return 25.4 mm. using Unitful InchType…

---

## [Multi Dimension Interpolation with Unitful](https://discourse.julialang.org/t/multi-dimension-interpolation-with-unitful/129043)

<div class="topic-metadata">

**Author:** [@luke-pikaart](https://discourse.julialang.org/u/luke-pikaart)\
**Replies:** 2\
**Last updated:** [May 15, 2025, 4:35pm UTC](https://discourse.julialang.org/t/multi-dimension-interpolation-with-unitful/129043 "2025-05-15T16:35:48Z")

</div>

I am trying to interpolate f : \\mathbb{R\_{units}} \\to \\mathbb{R\_{units}}^3 where there are unitful units on both the grid and the data. I found this example that showed me how to get f : \\mathbb{R} \\to \\mathbb{R}^3 in…

---

## [Unitful @refunit converts to other length units](https://discourse.julialang.org/t/unitful-refunit-converts-to-other-length-units/128327)

<div class="topic-metadata">

**Author:** [@prittjam](https://discourse.julialang.org/u/prittjam)\
**Replies:** 1\
**Last updated:** [April 24, 2025, 11:14am UTC](https://discourse.julialang.org/t/unitful-refunit-converts-to-other-length-units/128327 "2025-04-24T11:14:46Z")

</div>

I define a pixel as a reference unit as follows @refunit px "px" Pixel Unitful.𝐋 true However, the following happens despite not defining its size, uconvert(u"mm", 1u"px") 1000 mm Is this expected?

---

## [Automatic Unit Conversion Function](https://discourse.julialang.org/t/automatic-unit-conversion-function/128121)

<div class="topic-metadata">

**Author:** [@HSnowden](https://discourse.julialang.org/u/HSnowden)\
**Replies:** 0\
**Last updated:** [April 16, 2025, 10:57am UTC](https://discourse.julialang.org/t/automatic-unit-conversion-function/128121 "2025-04-16T10:57:33Z")

</div>

Hi Is it possible in Unitful.jl or DynamicQuantities.jl given a set of preferred units e.g. \[u"ms",u"mm",u"mJ",u"g"\] to have a function that can convert any given value e.g. 10u"W" to the correct units. I have tried upr…

---

## [Call original method when redefining a method. (Compact float printing in IJulia)](https://discourse.julialang.org/t/call-original-method-when-redefining-a-method-compact-float-printing-in-ijulia/74111)

<div class="topic-metadata">

**Author:** [@tfiers](https://discourse.julialang.org/u/tfiers)\
**Replies:** 6\
**Last updated:** [April 6, 2025, 5:24am UTC](https://discourse.julialang.org/t/call-original-method-when-redefining-a-method-compact-float-printing-in-ijulia/74111 "2025-04-06T05:24:25Z")

</div>

I want to print floats (and derived types such as Unitful.Quantity{Float64, …}) compactly in IJulia / the REPL. E.g. 0.1\*3 should be echoed as 0.3 and not 0.30000000000000004. Likewise, 0.1\*3mV should be 0.3 mV and not…

---

## [\[ANN\] UnitfulTensors.jl: Efficient arrays with units](https://discourse.julialang.org/t/ann-unitfultensors-jl-efficient-arrays-with-units/114028)

<div class="topic-metadata">

**Author:** [@anonymous\_shrew](https://discourse.julialang.org/u/anonymous_shrew)\
**Replies:** 17\
**Last updated:** [March 26, 2025, 7:17pm UTC](https://discourse.julialang.org/t/ann-unitfultensors-jl-efficient-arrays-with-units/114028 "2025-03-26T19:17:25Z")

</div>

Hello everyone! I wrote a package UnitfulTensors.jl for working efficiently with arrays of physical quantities. It implements most of the LinearAlgebra functionality, but with physical units (including arrays with mixe…

---

## [Still looking for a way to use units meaningfully with SciML ecosystem](https://discourse.julialang.org/t/still-looking-for-a-way-to-use-units-meaningfully-with-sciml-ecosystem/103678)

<div class="topic-metadata">

**Author:** [@Ickaser](https://discourse.julialang.org/u/Ickaser)\
**Replies:** 17\
**Last updated:** [January 29, 2025, 11:47am UTC](https://discourse.julialang.org/t/still-looking-for-a-way-to-use-units-meaningfully-with-sciml-ecosystem/103678 "2025-01-29T11:47:11Z")

</div>

I’ve spent frustrating hours now working on an optimization problem across what should be a relatively simple set of ODEs. I am working in a field where some very commonly used units are frankly unpleasant (e.g. cm^2\\cd…

---

## [Any suggestions for implementing parametric unit conversions?](https://discourse.julialang.org/t/any-suggestions-for-implementing-parametric-unit-conversions/124560)

<div class="topic-metadata">

**Author:** [@kapple](https://discourse.julialang.org/u/kapple)\
**Replies:** 0\
**Last updated:** [January 9, 2025, 1:58am UTC](https://discourse.julialang.org/t/any-suggestions-for-implementing-parametric-unit-conversions/124560 "2025-01-09T01:58:24Z")

</div>

I have the following table of unit conversions for wave attenuation rates. For example, The unitless quantity (units of “1”) is known as the loss tangent. In the spirit of Unitful.jl and/or DynamicQuantities.jl o…

---

## [Percent written as x%](https://discourse.julialang.org/t/percent-written-as-x/123735)

<div class="topic-metadata">

**Author:** [@Lincoln\_Hannah](https://discourse.julialang.org/u/Lincoln_Hannah)\
**Replies:** 7\
**Last updated:** [December 13, 2024, 1:36am UTC](https://discourse.julialang.org/t/percent-written-as-x/123735 "2024-12-13T01:36:53Z")

</div>

macro %(x) Unitful.percent(.01x) end @% 12 #12 % Is there a function or macro that would allow 12% instead of @% 12

---

## [Changing the basic type of a Unitful quantity](https://discourse.julialang.org/t/changing-the-basic-type-of-a-unitful-quantity/119665)

<div class="topic-metadata">

**Author:** [@Maurizio\_Tomasi](https://discourse.julialang.org/u/Maurizio_Tomasi)\
**Replies:** 2\
**Last updated:** [September 22, 2024, 10:26am UTC](https://discourse.julialang.org/t/changing-the-basic-type-of-a-unitful-quantity/119665 "2024-09-22T10:26:34Z")

</div>

I’m developing some electromagnetic code and want to use Unitful.jl thoroughly to make sure that data structures and algorithms are physically consistent. One feature I would like to have is the ability to quickly set u…

---

## [Unitful and generic function types](https://discourse.julialang.org/t/unitful-and-generic-function-types/119198)

<div class="topic-metadata">

**Author:** [@mesonepigreco](https://discourse.julialang.org/u/mesonepigreco)\
**Replies:** 3\
**Last updated:** [September 9, 2024, 5:50am UTC](https://discourse.julialang.org/t/unitful-and-generic-function-types/119198 "2024-09-09T05:50:15Z")

</div>

I have a function not using Unitful that reads like function foo(x :: Matrix{T}, y :: Vector{T}) where T my\_array = zeros(T, 100) # other stuff end Now, I want to implement my code using Unitful to make it eas…

---

## [DynamicQuantities.jl v0.7.0: efficient and type-stable physical quantities](https://discourse.julialang.org/t/dynamicquantities-jl-v0-7-0-efficient-and-type-stable-physical-quantities/103709)

<div class="topic-metadata">

**Author:** [@MilesCranmer](https://discourse.julialang.org/u/MilesCranmer)\
**Replies:** 48\
**Last updated:** [August 27, 2024, 3:21pm UTC](https://discourse.julialang.org/t/dynamicquantities-jl-v0-7-0-efficient-and-type-stable-physical-quantities/103709 "2024-08-27T15:21:50Z")

</div>

Happy to share DynamicQuantities.jl v0.7.0! The package has had some major changes over the last few versions, so I think it deserved a new post. DynamicQuantities defines a simple statically-typed Quantity ty…

---

## [Wrapping Unitful macros](https://discourse.julialang.org/t/wrapping-unitful-macros/95171)

<div class="topic-metadata">

**Author:** [@jar1](https://discourse.julialang.org/u/jar1)\
**Replies:** 2\
**Last updated:** [March 18, 2023, 9:44pm UTC](https://discourse.julialang.org/t/wrapping-unitful-macros/95171 "2023-03-18T21:44:54Z")

</div>

Inspired by a commenter on Unitful.jl I’m trying to do unitful calculations with bookshelves: how many books do I have in 10 book cases? (20book / shelf) \* (8shelf / case) \* (10case) == 1600book I would like to replace…

---

## [\`mergewith\` issue with \`Unitful\`](https://discourse.julialang.org/t/mergewith-issue-with-unitful/111087)

<div class="topic-metadata">

**Author:** [@mlhetland](https://discourse.julialang.org/u/mlhetland)\
**Replies:** 9\
**Last updated:** [March 3, 2024, 11:28pm UTC](https://discourse.julialang.org/t/mergewith-issue-with-unitful/111087 "2024-03-03T23:28:07Z")

</div>

I’ve been using mergewith(+, …) with Dicts containing Unitful values, and it worked great for a while … until it suddenly didn’t. And slight reorganization of the arguments made it work again, so I’m not quite sure what’…

---

## [Error in dblquad integration with Unitful and MonteCarloMeasurements](https://discourse.julialang.org/t/error-in-dblquad-integration-with-unitful-and-montecarlomeasurements/110420)

<div class="topic-metadata">

**Author:** [@GSavvidis](https://discourse.julialang.org/u/GSavvidis)\
**Replies:** 5\
**Last updated:** [February 22, 2024, 7:00pm UTC](https://discourse.julialang.org/t/error-in-dblquad-integration-with-unitful-and-montecarlomeasurements/110420 "2024-02-22T19:00:05Z")

</div>

Hello everyone, This is my first post so apologies in advance for any mistakes in the question format. I have been trying to calculate an integral of two variables using dblquad. The function to be integrated contains …

---

## [\`Unitful\`: define units in module and use them outside](https://discourse.julialang.org/t/unitful-define-units-in-module-and-use-them-outside/108059)

<div class="topic-metadata">

**Author:** [@ryofurue](https://discourse.julialang.org/u/ryofurue)\
**Replies:** 14\
**Last updated:** [December 27, 2023, 10:38pm UTC](https://discourse.julialang.org/t/unitful-define-units-in-module-and-use-them-outside/108059 "2023-12-27T22:38:17Z")

</div>

I’m reading the documentation (linked at the bottom of this message) about how to define new units and have come up with a module like this module MyUnits using Unitful Unitful.register(@\_\_MODULE\_\_) # What does this do…

---

## [Typed Units instead of parameterized (Unitful) or exponent-tracking (DynamicQuantities)?](https://discourse.julialang.org/t/typed-units-instead-of-parameterized-unitful-or-exponent-tracking-dynamicquantities/105735)

<div class="topic-metadata">

**Author:** [@bcon](https://discourse.julialang.org/u/bcon)\
**Replies:** 8\
**Last updated:** [December 22, 2023, 1:56am UTC](https://discourse.julialang.org/t/typed-units-instead-of-parameterized-unitful-or-exponent-tracking-dynamicquantities/105735 "2023-12-22T01:56:53Z")

</div>

Adding units to a package greatly obfuscates error messages, slowing development. If you share this annoyance I’d appreciate your thoughts on a package, ‘UnitTypes’, that simply treats units as types. The package would …

---

## [Prevent Unitful.jl conversion between monetary units](https://discourse.julialang.org/t/prevent-unitful-jl-conversion-between-monetary-units/104712)

<div class="topic-metadata">

**Author:** [@sstroemer](https://discourse.julialang.org/u/sstroemer)\
**Replies:** 2\
**Last updated:** [November 22, 2023, 7:53am UTC](https://discourse.julialang.org/t/prevent-unitful-jl-conversion-between-monetary-units/104712 "2023-11-22T07:53:56Z")

</div>

I’ve tried defining two different monetary units using using Unitful: @dimension, @refunit, @u\_str, uconvert @dimension MU "MU" MonetaryUnit @refunit USD "USD" USDollar MU false @refunit EUR "EUR" Euro MU false which …

---

## [How To Properly Use Unitful](https://discourse.julialang.org/t/how-to-properly-use-unitful/40295)

<div class="topic-metadata">

**Author:** [@acdupont](https://discourse.julialang.org/u/acdupont)\
**Replies:** 13\
**Last updated:** [October 31, 2023, 2:58pm UTC](https://discourse.julialang.org/t/how-to-properly-use-unitful/40295 "2023-10-31T14:58:36Z")

</div>

I’m using Unitful for the first time and would like direction on the proper way to use it. For my use case, I am creating a struct that I would like to store a specific unit because the value is being passed to such thin…

---

## [Sum of temperature values with Unitful.jl](https://discourse.julialang.org/t/sum-of-temperature-values-with-unitful-jl/104714)

<div class="topic-metadata">

**Author:** [@fnoessler](https://discourse.julialang.org/u/fnoessler)\
**Replies:** 3\
**Last updated:** [October 8, 2023, 6:37pm UTC](https://discourse.julialang.org/t/sum-of-temperature-values-with-unitful-jl/104714 "2023-10-08T18:37:13Z")

</div>

Hello, is there a way to calculate the (cumulative) sum of temperature values in °C with Unitful.jl? I know this does not have a direct physical meaning. Nonetheless, it would be nice to keep the °C unit attached to my…

---

## [Unitful quantities of something](https://discourse.julialang.org/t/unitful-quantities-of-something/101978)

<div class="topic-metadata">

**Author:** [@jar1](https://discourse.julialang.org/u/jar1)\
**Replies:** 4\
**Last updated:** [September 19, 2023, 2:02pm UTC](https://discourse.julialang.org/t/unitful-quantities-of-something/101978 "2023-09-19T14:02:33Z")

</div>

Say I want to represent concentrations like “milligrams of salt per milligrams of sugar”. Unitful.jl doesn’t seem to support this: julia\> typeof(3u"mg"/100u"mg") Float64 What would you suggest?

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