# Integral and unit of measurement

Is there a kind of "formalism" which define how unit measures come out from integration?

An example: given a point $P(x,y,z) \in \mathbb{R}^3$ there is the concept of mass $m$ associated to this point. Mass is measured in $\text{kg,g,lb,...}$ I indicate the generic unite measure of the mass $[m]$. Now, there is also the concept of density of mass $\rho(x,y,z)$ which is a (scalar) function which represents "mass per unit volume", or also $\frac{[m]}{[s]^3}$ (where $[s]$ is the unit measure of space), e.g. if we take a constant density over a volume, to know the mass of the volume it suffices to multiply density $\rho$ with volume $V$. The effect of this multiplication is coherent with unit measures involved.

Now, in general for non-constant density function, one needs to integrate the function over the volume to know mass:

$m=\int_V \rho(x,y,z)\text{d}\tau$ where $\tau$ is the volume element.

Now, integrals are pure mathematical objects, how can I relate the fact that an integral is not only (naively) "a product of the integrand for the measure of the space of integration" with the fact that, in the end, there will be $[m]=\frac{[m]}{[s]^3} [s]^3$

Now, naively I can argument something like this $\int_{[s^3]} \frac{[m]}{[s]^3} \text{d}([s^3])$, but the integrand is constant so $\frac{[m]}{[s]^3} \int_{[s^3]} \text{d}([s]^3)=[m]$. But here there is no mathematical formalism, only a naive thought about such an "integral of unit measures" sounds to me.

Is there actually an ad-hoc formal argument for this problem?

I guess the simplest way to formalise it is to write dimensionful quantities as a product of a dimenionless number and a constant dimensionful parameter. In this way you get e.g. $\rho=\bar{\rho}\times [\rho]$, with $\bar\rho$ dimensionless and $[\rho]$ the appropriate unit. Now if ypou change your unit of density, you get a rescaling $[\rho]\to \lambda [\rho]$ which you can absorb into the dimensionless prefactor. Of course, this is just a slightly fanciefied way of writing a quantity as value times unit.
The same trick works for the integration measure - at least for Riemannian integrals, the measure is a limit of small actual volume elements, and the $\text{d}v$ rescales if you change the units.