# Unitful one(T) = 1.0 (without units). What is the alternative?

**URL:** https://discourse.julialang.org/t/unitful-one-t-1-0-without-units-what-is-the-alternative/71024
**Category:** General Usage
**Tags:** unitful
**Created:** [November 5, 2021, 7:14pm UTC](https://discourse.julialang.org/t/unitful-one-t-1-0-without-units-what-is-the-alternative/71024 "2021-11-05T19:14:09Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)
#### Post date: [November 5, 2021, 7:14pm UTC](https://discourse.julialang.org/t/unitful-one-t-1-0-without-units-what-is-the-alternative/71024/1 "2021-11-05T19:14:09Z")

</div>

Basically:

```julia
julia> using Unitful

julia> x = 1.0u"nm"
1.0 nm

julia> zero(typeof(x))
0.0 nm

julia> one(typeof(x))
1.0

julia>

```

Why `one(typeof(x))` is not `1.0 nm`? And which is the alternative to using `one` for unit propagation if one has to do something like

```julia
julia> f(x::T) = x + one(T)/2
f (generic function with 1 method)

julia> f(1.0u"nm")
ERROR: DimensionError: 1.0 nm and 0.5 are not dimensionally compatible.
Stacktrace:

```

edit:

`T(0.5)` is the alternative.

If anyone has further comments, please let me know.

---

<div class="post-metadata">

### Author: ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)
#### Post date: [November 5, 2021, 7:19pm UTC](https://discourse.julialang.org/t/unitful-one-t-1-0-without-units-what-is-the-alternative/71024/2 "2021-11-05T19:19:01Z")

</div>

```julia
julia> oneunit(typeof(x))
1.0 nm

```

`one` is defined as the multiplicative identity which wouldn’t be true if it was unitful.

---

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [February 21, 2022, 2:16pm UTC](https://discourse.julialang.org/t/unitful-one-t-1-0-without-units-what-is-the-alternative/71024/3 "2022-02-21T14:16:21Z")

</div>

2 posts were split to a new topic: [Zero and zerounit, analogous to one and oneunit?](https://discourse.julialang.org/t/zero-and-zerounit-analogous-to-one-and-oneunit/76841)
