Engee documentation

How units are displayed

By default, exponents on units or dimensions are indicated using Unicode superscripts on macOS and without superscripts on other operating systems. You can set the environment variable UNITFUL_FANCY_EXPONENTS to either true or false to force using or not using the exponents. You can also set the :fancy_exponent IO context property to either true or false to force using or not using the exponents.

BracketStyle(x)
BracketStyle(typeof(x))

BracketStyle specifies whether the numeric value of a Quantity is printed in brackets (and what kind of brackets). Three styles are defined:

  • NoBrackets(): this is the default, for example used for real numbers: 1.2 m

  • RoundBrackets(): used for complex numbers: (2.5 + 1.0im) V

  • SquareBrackets(): used for Level/Gain: [3 dB] Hz^-1

abbr(x) provides abbreviations for units or dimensions. Since a method should always be defined for each unit and dimension type, absence of a method for a specific unit or dimension type is likely an error. Consequently, we return ❓ for generic arguments to flag unexpected behavior.

prefix(x::Unit)

Returns a string representing the SI prefix for the power-of-ten held by this particular unit.

show(io::IO, x::Quantity)

Show a unitful quantity by calling showval on the numeric value, appending a space, and then calling show on a units object U().

show(io::IO, x::Unitlike)

Call Unitful.showrep on each object in the tuple that is the type variable of a Unitful.Units or Unitful.Dimensions object.

showrep(io::IO, x::Unit)

Show the unit, prefixing with any decimal prefix and appending the exponent as formatted by Unitful.superscript.

showrep(io::IO, x::Dimension)

Show the dimension, appending any exponent as formatted by Unitful.superscript.

showval(io::IO, x::Number, brackets::Bool=true)

Show the numeric value x of a quantity. Depending on the type of x, the value may be enclosed in brackets (see BracketStyle). If brackets is set to false, the brackets are not printed.

superscript(i::Rational; io::Union{IO, Nothing} = nothing)

Returns exponents as a string.

This function returns the value as a string. It does not print to io. io is only used for IO context values. If io contains the :fancy_exponent property and the value is a Bool, this value will override the behavior of fancy exponents.