distance
Distance units, including imperial and SI units
You're viewing an older version of this page (#683). View the current version.
Interface
#include <codecogs/units/convert/distance.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) |
| Distance | ||||
| Meter | metre | m | unit_m | 1 |
| Feet | Foot | ft | unit_ft | 3.280839895 |
| Furlongs | Furlong | fur | unit_fur | 0.00497097 |
| Inches | Inch | in | unit_in | 39.37007874 |
| Light years | Lightyears | ly | unit_ly | 1.06E-16 |
| Miles | Miles | mile | unit_mile | 0.000621371 |
| Nautical Miles | Nautical Mile | nmile | unit_nmile | 0.000539957 |
| Parsecs | Parsec | psc | unit_psc | 3.24E-17 |
| Yards | Yard | yd | unit_yd | 1.093613298 |
FUNCTION
distance
Converts a distance from one unit to another.
Example 1
#include <iostream>
#include <codecogs/units/convert/distance.h>
using namespace Units::Convert::Distance;
int main()
{
std::cout << "distance(10.2,unit_m, unit_ft)=" << distance(10.2,unit_m, unit_ft);
return 0;
}Output:
distance(10.2,unit_m, unit_ft)= 33.46456693Parameters
number
the value in from_unit 's to convert
from_unit
an enumerated value of the initial distance type
to_unit
an emuerated value of the output distance type
Returns
the value in the converted unit.
This function's source code is only visible to registered users — documentation and the calculator above are free to use either way. Sign in to see it.