Mathematically, the concept of a physical dimension is expressed using one-dimensional vector spaces and their tensor products.
For example, consider mass.
You can add masses together and you know how to multiply a mass by a real number.
Thus, masses should form a one-dimensional real vector space $M$.
The same reasoning applies to other physical quantities, like length, time, temperature, etc.
Denote the corresponding one-dimensional vector spaces by $L$, $T$, etc.
When you multiply (say) some mass $m∈M$ and some length $l∈L$,
the result is $m⊗l∈M⊗L$.
Here $M⊗L$ is another one-dimensional real vector space,
which is capable of “storing” physical quantities of dimension mass times length.
Multiplicative inverses live in the dual space:
if $m∈M$, then $m^{-1}∈M^*$, where $\def\Hom{\mathop{\rm Hom}} \def\R{{\bf R}} M^*=\Hom(M,\R)$.
The element $m^{-1}$ is defined as the unique element in $M^*$
such that $m^{-1}(m)=1$, where $-(-)$ denotes the evaluation
of a linear functional on $M$ on an element of $M$.
Observe that $m ⊗ m^{-1} ∈ M⊗M^* ≅ \R$, where the latter canonical isomorphism
sends $(f,m)$ to $f(m)$, so $m^{-1}$ is indeed the inverse of $m$.
Next, you can also define powers of physical quantities,
i.e., $m^t$, where $m∈M$ is a mass and $t∈\R$ is a real number.
This is done using the notion of a density from differential geometry.
(The case $\def\C{{\bf C}} t\in\C$ works similarly, but with
complex one-dimensional vector spaces.)
In order to do this, we must make $M$ into an oriented vector space.
For a one-dimensional vector space, this simply means that
we declare one out of the two half-rays in $M∖\{0\}$ to be positive,
and denote it by $M_{>0}$.
This makes perfect sense for physical quantities like mass, length, temperature.
Once you have an orientation on $M$,
you can define $\def\Dens{\mathop{\rm Dens}} \Dens_d(M)$
for $d∈\R$ as the one-dimensional (oriented) real vector space
whose elements are equivalence classes of pairs $(a,m)$,
where $a∈\R$, $m∈M_{>0}$.
The equivalence relation is defined as follows:
$(a,b⋅m)∼(a b^d,m)$ for any $b∈\R_{>0}$.
The vector space operations are defined as follows:
$0=(0,m)$ for some $m∈M_{>0}$,
$-(a,m)=(-a,m)$,
$(a,m)+(a',m)=(a+a',m)$,
and $s(a,m)=(sa,m)$.
It suffices to add pairs with the same
second component $m$ because the equivalence relation allows you to change the second component arbitrarily.
Once we have defined $\Dens_d(M)$, given $m∈M_{>0}$ and $d∈\R$,
we define $m^d∈\Dens_d(M)$ as the equivalence class of the pair $(1,m)$.
It is easy to verify that all the usual laws of arithmetic,
like $m^d m^e = m^{d+e}$, $m^d n^d = (mn)^d$, etc.,
are satisfied, provided that multiplication and reciprocals are interpreted as explained above.
Using the power operation operations we just defined,
we can now see that the equivalence class of $(a,m)$
is equal to $a⋅m^d$, where $m∈M_{>0}$, $m^d∈\Dens_d(M)_{>0}$,
and $a⋅m^d∈\Dens_d(M)$.
This makes the meaning of the equivalence relation clear.
In particular, for $d=-1$ we have a canonical isomorphism $\Dens_{-1}(M)→M^*$
that sends the equivalence class of $(1,m)$ to the element $m^{-1}∈M^*$ defined above,
so the two notions of a reciprocal element coincide.
If you are dealing with temperature without knowing about the absolute zero,
it can be modeled as a one-dimensional real affine space.
That is, you can make sense of a linear combination
$$a_1 t_1 + a_2 t_2 + a_3 t_3$$
of temperatures $t_1$, $t_2$, $t_3$
as long as $a_1+a_2+a_3=1$,
and you don't need to know about the absolute zero to do this.
The calculus of physical quantities can be extended
to one-dimensional real affine spaces without much difficulty.
None of the above constructions make any noncanonical choices of
physical units (such as a unit of mass, for example).
Of course, if you do fix such a unit $μ∈M_{>0}$, you can construct
an isomorphism $\R→\Dens_d(M)$ that sends $a∈\R$ to $aμ^d$,
and the above calculus (including the power operations)
is identified with the usual operations on real numbers.
In general relativity, we no longer have a single one-dimensional
vector space for length.
Instead, we have the tangent bundle,
whose elements model (infinitesimal) displacements.
Thus, physical quantities no longer live in a fixed one-dimensional
vector space, but rather are sections of a one-dimensional
vector bundle constructed from the tangent bundle.
For example, the volume is an element of the total space
of the line bundle of 1-densities $\Dens_1(T M)$,
and the length is now given by the line-bundle of $λ$-densities $\Dens_λ(T M)$, where $λ=1/\dim M$.