From: Ross MacGregor (ross__macgregor_at_[hidden])
Date: 2003-10-23 05:13:23
Matthias Troyer wrote:
> I want to disagree here. I know particle physicists who use singe
> precision (float) numbers in some of their calculations. If instead of a
> common choice of units where hbar=1 one uses SI unites, where hbar is
> about about 1e-34, there will be problems. Even worse problems come when
> hbar^2 is needed.
> Since for many calculations I do in quantum mechanics a natural set of
> units is where hbar, the speed of light, and the charge of the electron
> are set to one, I would not like to be forced to use SI units.
What if we applied a scaling factor to the units so they can be
converted to SI units.
For example if you want your basic unit of length to be 299,792,458
meters and you wanted your calculations to use floats. You may want to
specify it like this:
si_unit<float, 2.99792458e+8, meter_t> light_meters;
si_unit<long double, 1.0, meter_t> meters;
light_meters x_lm = 2500;
light_meters y_lm = 10;
light_meters z_lm = x_lm + y_lm;
meters m = lm; // warning possible loss of precision
We are essentially creating a custom floating point value, but only
incurring the overhead during unit conversion.
-- Ross MacGregor
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk