Density units, including imperial and SI units

View versions (1)

Interface

#include <codecogs/units/convert/density.h>

using namespace Units::Convert;

Overview

The standard measurement units are:

Unit names Alternate names / spellings Abbreviation Enumeration Code Conversion Rate (relative to first unit)
Density
Grams/Meter3 Grams/Metre3 g/cu m unit_g_m3 1
Ounces/Gallon Ounce/Gallon Oz/gal unit_Oz_gal 0.000133526
Pounds/Foot3 Pounds/Feet3 lb/cu ft unit_lb_ft3 6.24E-05
Pounds/Inch3 Pound/Inch3 lb/cu in unit_lb_in3 3.61E-08
Tons/Yard3 Tonne/Yard3 T/cu yd unit_T_yd3 1.44E-06
GPL Licence — free for non commercial use. See Licence details.

FUNCTION

density

Converts a density from one unit to another.

Example 1

#include <iostream>
#include <codecogs/units/convert/density.h>

using namespace Units::Convert;
int main()
{
  std::cout << "density(10.2,unit_g_m3, unit_lb_in3)=" << density(1500000,unit_g_m3, unit_lb_in3);

  return 0;
}

Output:

density(1500000,unit_g_m3, unit_lb_in3)= 0.054190938

Parameters

number
the value in from_unit 's to convert
from_unit
an enumerated value of the initial density type
to_unit
an emuerated value of the output density type

Returns

the value in the converted unit.

Conversion between incompatible types will throw an error

Author

will