Re: physical constants header file

Discussion in 'C++' started by rossum, Oct 18, 2004.

  1. rossum

    rossum Guest

    On Sat, 16 Oct 2004 19:58:18 -0700, "E. Robert Tisdale"
    <> wrote:

    >Please find attached the physical constants header file physical.h
    >
    >It defines conversion factors to mks units.


    [snip]

    >namespace physical {
    > namespace unit { // conversion factor

    [snip]
    > const double dollar = 1.0;
    > const double dollars = dollar;
    > const double cent = dollar/100.0;
    > const double cents = cent;

    I have never thought of dollar as a physical unit. Namespace currency
    perhaps.
    const double pound = 1.0;
    const double penny = pound / 100.0;
    const double pence = penny;
    const double euro = 1.0;
    etc.

    [snip]
    I have added UK English/European spellings. meter --> metre etc.
    > // SI units (mks)
    > // length
    > const double meter = 1.0;
    > const double meters = meter;

    const double metre = meter;
    const double metres = meter;

    > const double m = meter;
    > const double kilometer = 1000.0*meters;
    > const double kilometers = kilometer;

    const double kilometre = kilometer;
    const double kilometres = kilometer;

    > const double km = kilometer;
    > const double decimeter = meters/10.0;
    > const double decimeters = decimeter;

    const double decimetre = decimeter;
    const double decimetres = decimeter;

    > const double dm = decimeter;
    > const double centimeter = meters/100.0;
    > const double centimeters = centimeter;

    const double centimetre = centimeter;
    const double centimetres = centimeter;

    > const double cm = centimeter;
    > const double millimeter = meters/1000.0;
    > const double millimeters = millimeter;

    const double millimetre = millimeter;
    const double millimetres = millimeter;

    > const double mm = millimeter;
    > const double micron = meter/1000000.0;
    > const double microns = micron;
    > const double nanometer = meter/1000000000.0;
    > const double nanometers = nanometer;

    const double nanometre = nanometer;
    const double nanometres = nanometer;

    > const double nm = nanometer;
    > const double decinanometer = meter/10000000000.0;
    > const double decinanometers = decinanometer;

    const double decinanometre = decinanometer;
    const double decinanometres = decinanometer;

    [snip]
    > // volume
    > const double stere = meter*meter*meter;
    > const double steres = stere;
    > const double liter = stere/1000.0;
    > const double liters = liter;

    const double litre = stere/1000.0;
    const double litres = liter;

    > const double l = liter;
    > const double milliliter = stere/1000000.0;
    > const double milliliters = milliliter;

    const double millilitre = milliliter;
    const double millilitres = milliliter;

    > const double ml = milliliter;
    > const double cc = milliliter;

    [snip]
    > }
    > // mass
    > const double kilogram = 1.0;
    > const double kilograms = kilogram;

    const double kilogramme = 1.0;
    const double kilogrammes = kilogram;

    > const double kg = kilogram;

    [snip]
    > const double gram = kilograms/1000.0;
    > const double grams = gram;

    const double gramme = kilograms/1000.0;
    const double grammes = gram;

    > const double g = gram;
    > const double milligram = kilogram/1000000.0;
    > const double milligrams = milligram;

    const double milligramme = kilogram/1000000.0;
    const double milligrammes = milligram;

    > const double mg = milligram;
    > namespace metric { // weight
    > const double carat = gram/5.0;
    > const double carats = carat;
    > const double ton = 1000.0*kilograms;
    > const double tons = ton;

    const double tonne = 1000.0*kilograms;
    const double tonnes = ton;

    You have namespace metric, but these two might be useful.
    const double metric_ton = ton;
    const double metric_tons = ton;

    > const double t = ton;
    > }

    [snip]
    > // spacial frequency
    > const double diopter = 1.0/meter;
    > const double diopters = diopter;

    const double dioptre = 1.0/meter;
    const double dioptres = diopter;

    [snip]


    rossum


    --

    The ultimate truth is that there is no Ultimate Truth
    rossum, Oct 18, 2004
    #1
    1. Advertising

  2. rossum wrote:

    > You have namespace metric, but these two might be useful.
    > const double metric_ton = ton;
    > const double metric_tons = ton;


    What's wrong with using metric::ton or metric::tons?
    E. Robert Tisdale, Oct 18, 2004
    #2
    1. Advertising

  3. rossum

    rossum Guest

    On Mon, 18 Oct 2004 15:04:16 -0700, "E. Robert Tisdale"
    <> wrote:

    >rossum wrote:
    >
    >> You have namespace metric, but these two might be useful.
    >> const double metric_ton = ton;
    >> const double metric_tons = ton;

    >
    >What's wrong with using metric::ton or metric::tons?

    Nothing at all. I was less sure about these two than the others,
    hence my comment.

    rossum



    --

    The ultimate truth is that there is no Ultimate Truth
    rossum, Oct 19, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. rossum
    Replies:
    1
    Views:
    326
    rossum
    Oct 18, 2004
  2. Richard Herring

    Re: physical constants header file

    Richard Herring, Oct 19, 2004, in forum: C++
    Replies:
    0
    Views:
    367
    Richard Herring
    Oct 19, 2004
  3. JKop
    Replies:
    2
    Views:
    321
  4. Gene Nygaard

    Re: physical constants header file

    Gene Nygaard, Oct 19, 2004, in forum: C++
    Replies:
    0
    Views:
    561
    Gene Nygaard
    Oct 19, 2004
  5. Howard
    Replies:
    18
    Views:
    678
Loading...

Share This Page