[boost] Re: Physical Quantities revisited
by Ross MacGregor other posts by this author
Oct 23 2003 3:34AM messages near this date
RE: [boost] Re: Physical Quantities revisited
|
RE: [boost] Re: Physical Quantities revisited
SOURCE
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
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Thread:
Andy Little
Andy Little
Andy Little
Andy Little
Andy Little
Andy Little
Andy Little
Jan Langer
Andy Little
Deane Yang
Paul A. Bristow
Phil Richards
Rene Jager
Deane Yang
Phil Richards
Andy Little
Deane Yang
Brock Peabody
Paul A. Bristow
Andy Little
Andy Little
Matthias Troyer
Paul A. Bristow
Ross MacGregor
Deane Yang
Paul A. Bristow
Deane Yang
Paul A. Bristow
Paul A. Bristow
David Abrahams
Jonathan de Halleux
Philip Miller
Deane Yang
Paul A. Bristow
Paul A. Bristow
David Abrahams
|