diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c096c7..fac7cac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Changelog +<<<<<<< HEAD ## Cldr_Units v3.16.5 This is the changelog for Cldr_units v3.16.4 released on April 11th, 2024. For older changelogs please consult the release tag on [GitHub](https://github.com/elixir-cldr/cldr_units/tags) @@ -8,6 +9,20 @@ This is the changelog for Cldr_units v3.16.4 released on April 11th, 2024. For * Fix spec for `Cldr.Unit.display_name/2`. Thanks to @ryotsu for the report. Closes #43. +## Cldr_Units v3.17.0 + +This is the changelog for Cldr_units v3.17.0 released on April 21st, 2024. For older changelogs please consult the release tag on [GitHub](https://github.com/elixir-cldr/cldr_units/tags) + +### Bug Fixes + +* Fixes canonical unit name formation. More units can now be resolved to a base unit and therefore compared and converted with other units. The primary change is to add elimination of common factors in "per" units. + +### Enhancements + +* Add conversion support for Beaufort. This conversion is non linear and therefore cannot be expressed using the normal unit conversion method. + +* `Cldr.Unit.Math.mult/2` and `Cldr.Unit.Math.div/2` now support scalar values as the second argument. Its therefore now possible to say `Cldr.Unit.Math.mult(Cldr.Unit.new!(:meter, 10), 2)`. + ## Cldr_Units v3.16.4 This is the changelog for Cldr_units v3.16.4 released on November 2nd, 2023. For older changelogs please consult the release tag on [GitHub](https://github.com/elixir-cldr/cldr_units/tags) @@ -30,7 +45,7 @@ This is the changelog for Cldr_units v3.16.2 released on June 15th, 2023. For o ### Bug Fixes -* Fix `Cldr.round/1` for float units. Thanks to @doughsay for the report. Closes #38. +* Fix `Cldr.Unit.round/1` for float units. Thanks to @doughsay for the report. Closes #38. ## Cldr_Units v3.16.1 diff --git a/LICENSE.md b/LICENSE.md index a9b25b8..7268ca1 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ ## License -Copyright 2017-2023 Kip Cole +Copyright 2017-2024 Kip Cole Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at diff --git a/TODO.md b/TODO.md index 84b02bb..e1cf544 100644 --- a/TODO.md +++ b/TODO.md @@ -1,4 +1,21 @@ # To Do list for Cldr Units +* Not all units are translatable in all locales - so what is the canonical list of units? +* How do we localise units that have no translation in a given locale? +* How do we get the measurement systems of units that have no conversion (since thats where the system data is kept) +* What is the intention of the new unit systems? + [ ] Support any unit in `Cldr.Unit.display_name/1` +[ ] Fix use of generic unit `:unit` +[ ] Math using scalars for mult and sub should work +[ ] Math with powers should work +[ ] Support `pown` notation for powers beyond square and cubic + + +# Notes + +* https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2981r1.html +* https://linux.die.net/man/1/units + + diff --git a/lib/cldr/unit.ex b/lib/cldr/unit.ex index 987fe1f..d873e0a 100644 --- a/lib/cldr/unit.ex +++ b/lib/cldr/unit.ex @@ -45,6 +45,28 @@ defmodule Cldr.Unit do format_options: [], backend: nil + defdelegate convert(unit_1, to_unit), to: Conversion + defdelegate convert!(unit_1, to_unit), to: Conversion + + defdelegate preferred_units(unit, backend, options), to: Preference + defdelegate preferred_units!(unit, backend, options), to: Preference + + defdelegate add(unit_1, unit_2), to: Math + defdelegate sub(unit_1, unit_2), to: Math + defdelegate mult(unit_1, unit_2), to: Math + defdelegate div(unit_1, unit_2), to: Math + + defdelegate add!(unit_1, unit_2), to: Math + defdelegate sub!(unit_1, unit_2), to: Math + defdelegate mult!(unit_1, unit_2), to: Math + defdelegate div!(unit_1, unit_2), to: Math + + defdelegate round(unit, places, mode), to: Math + defdelegate round(unit, places), to: Math + defdelegate round(unit), to: Math + + defdelegate compare(unit_1, unit_2), to: Math + @root_locale_name Cldr.Config.root_locale_name() # See https://unicode.org/reports/tr35/tr35-general.html#Case @@ -94,14 +116,8 @@ defmodule Cldr.Unit do :narrow ] - @measurement_systems Cldr.Config.measurement_systems() - @system_names Map.keys(@measurement_systems) |> Enum.sort() - - @measurement_system_keys [ - :default, - :paper_size, - :temperature - ] + @system_names Cldr.Config.measurement_systems() + |> Enum.sort() # Converts a list of atoms into a typespec type = &Enum.reduce(&1, fn x, acc -> {:|, [], [x, acc]} end) @@ -113,7 +129,6 @@ defmodule Cldr.Unit do @type grammatical_gender :: unquote(type.(@grammatical_gender)) @type grammatical_case :: unquote(type.(@grammatical_case)) @type measurement_system :: unquote(type.(@system_names)) - @type measurement_system_key :: unquote(type.(@measurement_system_keys)) @type style :: unquote(type.(@styles)) @type value :: Cldr.Math.number_or_decimal() @type locale :: Locale.locale_name() | LanguageTag.t() @@ -143,28 +158,6 @@ defmodule Cldr.Unit do @units Cldr.Config.units() - defdelegate convert(unit_1, to_unit), to: Conversion - defdelegate convert!(unit_1, to_unit), to: Conversion - - defdelegate preferred_units(unit, backend, options), to: Preference - defdelegate preferred_units!(unit, backend, options), to: Preference - - defdelegate add(unit_1, unit_2), to: Math - defdelegate sub(unit_1, unit_2), to: Math - defdelegate mult(unit_1, unit_2), to: Math - defdelegate div(unit_1, unit_2), to: Math - - defdelegate add!(unit_1, unit_2), to: Math - defdelegate sub!(unit_1, unit_2), to: Math - defdelegate mult!(unit_1, unit_2), to: Math - defdelegate div!(unit_1, unit_2), to: Math - - defdelegate round(unit, places, mode), to: Math - defdelegate round(unit, places), to: Math - defdelegate round(unit), to: Math - - defdelegate compare(unit_1, unit_2), to: Math - @doc """ Returns the units that are defined for a given category (such as :volume, :length) @@ -216,17 +209,17 @@ defmodule Cldr.Unit do :hour, :inch, ...] """ - # Beaufort not fully supported yet - @translatable_units @units_by_category - |> Map.values() - |> List.flatten() - |> List.delete(:generic) - |> List.delete(:beaufort) - |> Kernel.++(Cldr.Unit.Additional.additional_units()) + @known_units Cldr.Unit.Conversions.conversions() + |> Map.keys() + |> Kernel.++(Cldr.Unit.Additional.additional_units()) + + @units_by_category @unit_tree + |> Map.delete(:compound) + |> Map.delete(:coordinate) @spec known_units :: [translatable_unit(), ...] def known_units do - @translatable_units + @known_units end @deprecated "Use Cldr.Unit.known_units/0" @@ -568,7 +561,7 @@ defmodule Cldr.Unit do ## Arguments * `unit string` is any string to be parsed and if - possible used to create a new `t:Cldr.Unit` + possible used to create a new `t:Cldr.Unit.t/0` * `options` is a keyword list of options @@ -837,7 +830,7 @@ defmodule Cldr.Unit do ## Arguments * `unit string` is any string to be parsed and if - possible used to create a new `t:Cldr.Unit` + possible used to create a new `t:Cldr.Unit.t/0` * `options` is a keyword list of options @@ -1079,7 +1072,7 @@ defmodule Cldr.Unit do ## Arguments * `list_or_number` is any number (integer, float or Decimal) or a - `t:Cldr.Unit` struct or a list of `t:Cldr.Unit` structs + `t:Cldr.Unit.t/0` struct or a list of `t:Cldr.Unit.t/0` structs * `backend` is any module that includes `use Cldr` and therefore is a `Cldr` backend module. The default is `Cldr.default_backend!/0`. @@ -1089,7 +1082,7 @@ defmodule Cldr.Unit do ## Options * `:unit` is any unit returned by `Cldr.Unit.known_units/0`. Ignored if - the number to be formatted is a `t:Cldr.Unit` struct + the number to be formatted is a `t:Cldr.Unit.t/0` struct * `:locale` is any valid locale name returned by `Cldr.known_locale_names/1` or a `Cldr.LanguageTag` struct. The default is `Cldr.get_locale/0` @@ -1147,7 +1140,7 @@ defmodule Cldr.Unit do {:ok, "1,234 megahertz"} iex> Cldr.Unit.to_string Cldr.Unit.new!(:megahertz, 1234), MyApp.Cldr, style: :narrow - {:ok, "1,234MHz"} + {:ok, "1,234Mhz"} iex> unit = Cldr.Unit.new!(123, :foot) iex> Cldr.Unit.to_string unit, MyApp.Cldr @@ -1205,13 +1198,13 @@ defmodule Cldr.Unit do for the current process's locale and backend or raises on error. - During processing any `:format_options` of a `t:Cldr.Unit` are merged with + During processing any `:format_options` of a `t:Cldr.Unit.t/0` are merged with `options` with `options` taking precedence. ## Arguments * `number` is any number (integer, float or Decimal) or a - `t:Cldr.Unit` struct + `t:Cldr.Unit.t/0` struct * `backend` is any module that includes `use Cldr` and therefore is a `Cldr` backend module. The default is `Cldr.default_backend!/0`. @@ -1221,7 +1214,7 @@ defmodule Cldr.Unit do ## Options * `:unit` is any unit returned by `Cldr.Unit.known_units/0`. Ignored if - the number to be formatted is a `t:Cldr.Unit` struct + the number to be formatted is a `t:Cldr.Unit.t/0` struct * `:locale` is any valid locale name returned by `Cldr.known_locale_names/0` or a `Cldr.LanguageTag` struct. The default is `Cldr.get_locale/0` @@ -1575,7 +1568,7 @@ defmodule Cldr.Unit do ## Arguments - * `unit` is any `t:Cldr.Unit` or any + * `unit` is any `t:Cldr.Unit.t/0` or any unit name returned by `Cldr.Unit.known_units/0`. * `options` is a keyword list of options. @@ -1613,7 +1606,7 @@ defmodule Cldr.Unit do display_name(unit, options) end - def display_name(unit, options) when unit in @translatable_units do + def display_name(unit, options) when unit in @known_units do style = Keyword.get(options, :style, @default_style) {locale, backend} = Cldr.locale_and_backend_from(options) @@ -1781,7 +1774,7 @@ defmodule Cldr.Unit do measurement_system?(unit, systems) end - def measurement_system?(unit, systems) when unit in @translatable_units and is_list(systems) do + def measurement_system?(unit, systems) when unit in @known_units and is_list(systems) do Enum.any?(measurement_systems_for_unit(unit), &(&1 in systems)) end @@ -1797,6 +1790,7 @@ defmodule Cldr.Unit do |> Map.get(:conversions) |> Enum.map(fn {unit, conversion} -> {unit, conversion.systems} end) |> Kernel.++(Cldr.Unit.Additional.systems_for_units()) + |> Enum.map(fn {unit, systems} -> {unit, Enum.sort(systems)} end) |> Map.new() @doc """ @@ -1805,7 +1799,7 @@ defmodule Cldr.Unit do ## Arguments - * `unit` is any `t:Cldr.Unit` or any unit + * `unit` is any `t:Cldr.Unit.t/0` or any unit returned by `Cldr.Unit.known_units/0` or a string unit name. @@ -1819,10 +1813,10 @@ defmodule Cldr.Unit do ## Examples iex> Cldr.Unit.measurement_systems_for_unit :foot - [:ussystem, :uksystem] + [:uksystem, :ussystem] iex> Cldr.Unit.measurement_systems_for_unit :meter - [:metric, :si] + [:metric, :prefixable, :si] iex> Cldr.Unit.measurement_systems_for_unit :invalid {:error, {Cldr.UnknownUnitError, "The unit :invalid is not known."}} @@ -1836,13 +1830,15 @@ defmodule Cldr.Unit do measurement_systems_for_unit(unit) end - def measurement_systems_for_unit(unit) when unit in @translatable_units do + def measurement_systems_for_unit(unit) when unit in @known_units do case Map.fetch(@systems_for_unit, unit) do {:ok, systems} -> systems :error -> measurement_systems_for_unit(Kernel.to_string(unit)) end end + + # Strip SI and power factors amd try the root # unit for prefix <- Cldr.Unit.Prefix.prefixes() do @@ -1860,13 +1856,13 @@ defmodule Cldr.Unit do # Decompose the unit recursively until there is a match on # a base unit, otherwise return an error def measurement_systems_for_unit(unit) when is_binary(unit) do - [first | rest] = String.split(unit, "_", parts: 2) + [first | _rest] = String.split(unit, "_", parts: 2) with {:ok, part_unit, _conversion} <- Cldr.Unit.validate_unit(first) do - measurement_systems_for_unit(part_unit) - else - _other -> - if rest == [], do: {:error, unit_error(unit)}, else: measurement_systems_for_unit(hd(rest)) + case Map.fetch(@systems_for_unit, part_unit) do + {:ok, systems} -> systems + :error -> {:error, no_known_measurement_systems_error(unit)} + end end end @@ -1880,37 +1876,11 @@ defmodule Cldr.Unit do ## Example iex> Cldr.Unit.known_measurement_systems() - %{ - metric: %{alias: nil, description: "Metric System"}, - uksystem: %{ - alias: :imperial, - description: "UK System of measurement: feet, pints, etc.; pints are 20oz" - }, - ussystem: %{alias: nil, description: "US System of measurement: feet, pints, etc.; pints are 16oz"}, - si: %{alias: nil, description: "SI System"} - } + [:astronomical, :jpsystem, :metric, :metric_adjacent, :person_age, :prefixable, :si, :si_acceptable, :uksystem, :ussystem] """ - @spec known_measurement_systems :: - %{measurement_system() => %{alias: atom(), description: String.t()}} - + @spec known_measurement_systems() :: list(measurement_system()) def known_measurement_systems do - @measurement_systems - end - - @doc """ - Return a list of known measurement system names. - - ## Example - - iex> Cldr.Unit.known_measurement_system_names() - [:metric, :si, :uksystem, :ussystem] - - """ - @doc since: "3.5.0" - @spec known_measurement_system_names :: [measurement_system(), ...] - - def known_measurement_system_names do @system_names end @@ -1959,7 +1929,7 @@ defmodule Cldr.Unit do @doc since: "3.4.0" @spec measurement_system_from_locale( Cldr.LanguageTag.t() | Cldr.Locale.locale_name(), - measurement_system_key() | Cldr.backend() + measurement_system() | Cldr.backend() ) :: measurement_system() | {:error, {module(), String.t()}} @@ -1997,7 +1967,7 @@ defmodule Cldr.Unit do @spec measurement_system_from_locale( Locale.locale_reference(), Cldr.backend(), - measurement_system_key() + measurement_system() ) :: measurement_system() | {:error, {module(), String.t()}} @@ -2062,8 +2032,8 @@ defmodule Cldr.Unit do ## Argument - * `unit` is either a `t:Cldr.Unit`, an `atom` or - a `t:String` + * `unit` is either a `t:Cldr.Unit.t/0`, an `atom` or + a `t:String.t/0` ## Returns @@ -2094,7 +2064,51 @@ defmodule Cldr.Unit do @deprecated "Use `Cldr.Unit.known_unit_categories/0" defdelegate unit_categories(), to: __MODULE__, as: :known_unit_categories - @unit_category_inverse_map Cldr.Map.invert(@units_by_category) |> Cldr.Map.stringify_keys() + @doc """ + Returns a mapping of base units to their respective + unit categories. + + Base units are a common unit for a given unit + category which are used in two scenarios: + + 1. When converting between units. If two units + have the same base unit they can be converted + to each other. See `Cldr.Unit.Conversion`. + + 2. When identifying the preferred units for a given + locale or territory, the base unit is used to + aid identification of preferences for given use + cases. See `Cldr.Unit.Preference`. + + ## Example + + => Cldr.Unit.base_unit_category_map + %{ + "kilogram_square_meter_per_cubic_second_ampere" => :voltage, + "kilogram_meter_per_meter_square_second" => :torque, + "square_meter" => :area, + "kilogram" => :mass, + "kilogram_square_meter_per_square_second" => :energy, + "revolution" => :angle, + "candela_per_square_meter" => :luminance, + ... + } + + """ + @base_unit_category_map Cldr.Config.units() + |> Map.get(:base_units) + # |> Kernel.++(Cldr.Unit.Additional.base_units()) + |> Enum.map(fn {k, v} -> {Kernel.to_string(v), k} end) + |> Map.new() + + @spec base_unit_category_map :: map() + def base_unit_category_map do + @base_unit_category_map + end + + @unit_category_inverse_map @units_by_category + |> Cldr.Map.invert() + |> Cldr.Map.stringify_keys() @doc false def unit_category_inverse_map do @@ -2106,8 +2120,8 @@ defmodule Cldr.Unit do ## Options - * `unit` is any unit returned by - `Cldr.Unit.new/2` + * `unit` is either a `t:Cldr.Unit.t/0`, an `atom` or + a `t:String.t/0` ## Returns @@ -2130,16 +2144,19 @@ defmodule Cldr.Unit do {:ok, :energy} iex> Cldr.Unit.unit_category "watt hour per light year" + {:ok, :force} + + iex> Cldr.Unit.unit_category "watt per kilogram" {:error, {Cldr.Unit.UnknownCategoryError, - "The category for \\"watt hour per light year\\" is not known."}} + "The category for \\"watt_per_kilogram\\" is not known."}} """ @spec unit_category(Unit.t() | String.t() | atom()) :: {:ok, category()} | {:error, {module(), String.t()}} - def unit_category(unit) when unit in @translatable_units do + def unit_category(unit) when unit in @known_units do case Map.fetch(@unit_category_inverse_map, Kernel.to_string(unit)) do {:ok, category} -> {:ok, category} :error -> {:error, unknown_category_error(unit)} @@ -2148,22 +2165,27 @@ defmodule Cldr.Unit do def unit_category(unit) do with {:ok, resolved_unit, conversion} <- validate_unit(unit) do - if resolved_unit in @translatable_units do + if resolved_unit in @known_units do unit_category(resolved_unit) else - unit_category(unit, conversion) + unit_category(resolved_unit, conversion) end end end @doc false def unit_category(unit, conversion) do - with {:ok, base_unit} <- BaseUnit.canonical_base_unit(conversion), - {:ok, category} <- Map.fetch(@unit_category_inverse_map, Kernel.to_string(base_unit)) do - {:ok, category} - else - :error -> {:error, unknown_category_error(unit)} - other -> other + with {:ok, base_unit} <- BaseUnit.canonical_base_unit(conversion) do + category = + Map.get(@unit_category_inverse_map, Kernel.to_string(unit)) || + Map.get(@unit_category_inverse_map, Kernel.to_string(base_unit)) || + Map.get(@base_unit_category_map, Kernel.to_string(base_unit)) + + if category do + {:ok, category} + else + {:error, unknown_category_error(unit)} + end end end @@ -2214,48 +2236,6 @@ defmodule Cldr.Unit do grammatical_gender(new!(1, unit), options) end - @base_unit_category_map Cldr.Config.units() - |> Map.get(:base_units) - # |> Kernel.++(Cldr.Unit.Additional.base_units()) - |> Enum.map(fn {k, v} -> {Kernel.to_string(v), k} end) - |> Map.new() - - @doc """ - Returns a mapping of base units to their respective - unit categories. - - Base units are a common unit for a given unit - category which are used in two scenarios: - - 1. When converting between units. If two units - have the same base unit they can be converted - to each other. See `Cldr.Unit.Conversion`. - - 2. When identifying the preferred units for a given - locale or territory, the base unit is used to - aid identification of preferences for given use - cases. See `Cldr.Unit.Preference`. - - ## Example - - => Cldr.Unit.base_unit_category_map - %{ - "kilogram_square_meter_per_cubic_second_ampere" => :voltage, - "kilogram_meter_per_meter_square_second" => :torque, - "square_meter" => :area, - "kilogram" => :mass, - "kilogram_square_meter_per_square_second" => :energy, - "revolution" => :angle, - "candela_per_square_meter" => :luminance, - ... - } - - """ - @spec base_unit_category_map :: map() - def base_unit_category_map do - @base_unit_category_map - end - @doc """ Returns the known styles for a unit. @@ -2448,15 +2428,15 @@ defmodule Cldr.Unit do * an `atom()` in which case the unit must be localizable in CLDR directly - * or a `t:String` in which case it is parsed + * or a `t:String.t/0` in which case it is parsed into a list of composable subunits that can be converted but are not guaranteed to be output as a localized string. ## Arguments - * `unit_name` is an `atom()` or `t:String`, supplied - as is or as part of an `t:Cldr.Unit` struct. + * `unit_name` is an `atom()` or `t:String.t/0`, supplied + as is or as part of an `t:Cldr.Unit.t/0` struct. ## Returns @@ -2472,7 +2452,7 @@ defmodule Cldr.Unit do A returned `unit_name` that is an atom is directly localisable (CLDR has translation data for the unit). - A `unit_name` that is a `t:String` is composed of + A `unit_name` that is a `t:String.t/0` is composed of one or more unit names that need to be resolved in order for the `unit_name` to be localised. @@ -2513,10 +2493,14 @@ defmodule Cldr.Unit do ]}} """ - def validate_unit(unit_name) when unit_name in @translatable_units do + def validate_unit(unit_name) when unit_name in @known_units do {:ok, unit_name, Conversions.conversion_for!(unit_name)} end + # def validate_unit(unit_name) when unit_name in @convertible_units do + # {:ok, unit_name, Conversions.conversion_for!(unit_name)} + # end + @aliases Alias.aliases() |> Map.keys() |> Enum.sort() def validate_unit(unit_name) when unit_name in @aliases do unit_name @@ -2823,6 +2807,14 @@ defmodule Cldr.Unit do } end + @doc false + def no_known_measurement_systems_error(unit) do + { + Cldr.Unit.UnknownMeasurementSystemError, + "The measurement systems for #{inspect unit} are not known" + } + end + @doc false def invalid_system_key_error(key) do { diff --git a/lib/cldr/unit/backend.ex b/lib/cldr/unit/backend.ex index 60d07e7..ac4d344 100644 --- a/lib/cldr/unit/backend.ex +++ b/lib/cldr/unit/backend.ex @@ -175,7 +175,7 @@ defmodule Cldr.Unit.Backend do {:ok, "1,234 megahertz"} iex> #{inspect(__MODULE__)}.to_string Cldr.Unit.new!(:megahertz, 1234), style: :narrow - {:ok, "1,234MHz"} + {:ok, "1,234Mhz"} iex> #{inspect(__MODULE__)}.to_string Cldr.Unit.new!(:megabyte, 1234), locale: "en", style: :unknown {:error, {Cldr.UnknownFormatError, "The unit style :unknown is not known."}} diff --git a/lib/cldr/unit/base_unit.ex b/lib/cldr/unit/base_unit.ex index dd474ab..74957a3 100644 --- a/lib/cldr/unit/base_unit.ex +++ b/lib/cldr/unit/base_unit.ex @@ -10,12 +10,20 @@ defmodule Cldr.Unit.BaseUnit do alias Cldr.Unit.Conversion alias Cldr.Unit.Parser + alias Cldr.Unit.Prefix alias Cldr.Unit @per "_per_" @currency_base Cldr.Unit.Parser.currency_base() @currencies Cldr.known_currencies() + @inverted_base_units_name Cldr.Config.units() + |> Map.get(:base_units) + |> Kernel.++(Cldr.Unit.Additional.base_units()) + |> Enum.uniq() + |> Map.new() + |> Map.values() + @doc """ Returns the canonical base unit name for a unit. @@ -63,7 +71,7 @@ defmodule Cldr.Unit.BaseUnit do |> merge_unit_names() |> sort_base_units() |> reduce_powers() - # |> reduce_factors() + |> reduce_factors() |> flatten_and_stringify() |> Unit.maybe_translatable_unit() |> wrap(:ok) @@ -85,8 +93,7 @@ defmodule Cldr.Unit.BaseUnit do |> resolve_unit_names() |> sort_base_units() |> reduce_powers() - - # |> reduce_factors() + |> reduce_factors() end defp canonical_base_subunit({currency, _conversion}) when currency in @currencies do @@ -224,74 +231,106 @@ defmodule Cldr.Unit.BaseUnit do false end + # Compare 2 base unit names and return a comparison :eq, :lt, :gt. + # Order is determined by the canonical order of units defined by CLDR + # returned by base_units_in_order/0. + + defp compare([_power_1, unit_1], [_power_2, unit_2]) do + compare(unit_1, unit_2) + end + + defp compare([_power_1, unit_1], unit_2) do + compare(unit_1, unit_2) + end + + defp compare(unit_1, [_power_2, unit_2]) do + compare(unit_1, unit_2) + end + + defp compare(unit_1, unit_2) when is_atom(unit_1) and is_atom(unit_2) do + order_1 = Map.fetch!(base_units_in_order(), unit_1) + order_2 = Map.fetch!(base_units_in_order(), unit_2) + + cond do + order_1 > order_2 -> :gt + order_1 < order_2 -> :lt + order_1 == order_2 -> :eq + end + end + # Reduce factors. When its a "per" unit then # we reduce the common factors. # This is important to ensure that base unit # comparisons work correctly across different units # of the same type. - # Currently not being used but in the future this - # might be required. - @doc false - def reduce_factors({[], denominator}) do - {[], denominator} + def reduce_factors(list) when is_list(list) do + list end - def reduce_factors({numerator, []}) do - {numerator, []} - end + def reduce_factors({numerator, denominator}) do + str_numerator = flatten_and_stringify(numerator) + str_denominator = flatten_and_stringify(denominator) - # Numerator and denominator cancel each other - def reduce_factors({[unit | rest_1], [unit | rest_2]}) do - # |> IO.inspect(label: "1") - reduce_factors({rest_1, rest_2}) + if is_base_unit(str_numerator) || is_base_unit(str_denominator) do + {numerator, denominator} + else + do_reduce_factors({numerator, denominator}) + end end - def reduce_factors({[[:square, unit] | rest_1], [unit | rest_2]}) do - # |> IO.inspect(label: "2") - reduce_factors({[unit | rest_1], rest_2}) + def do_reduce_factors({[], denominator}) do + {[], denominator} end - def reduce_factors({[unit | rest_1], [[:square, unit] | rest_2]}) do - # |> IO.inspect(label: "3") - reduce_factors({rest_1, [unit | rest_2]}) + def do_reduce_factors({numerator, []}) do + {numerator, []} end - def reduce_factors({[unit | rest_1], [[:cubic, unit] | rest_2]}) do - # |> IO.inspect(label: "4") - reduce_factors({rest_1, [[:square, unit] | rest_2]}) + # Numerator and denominator cancel each other + def do_reduce_factors({[unit | rest_1], [unit | rest_2]}) do + do_reduce_factors({rest_1, rest_2}) end - def reduce_factors({[[:square, unit] | rest_1], [[:square, unit] | rest_2]}) do - # |> IO.inspect(label: "5") - reduce_factors({rest_1, rest_2}) + # When we have the same unit, but one of them is raised to a + # power, we can reduce the power by one. This is true in both directions. + def do_reduce_factors({[[power, unit] | rest_1], [unit | rest_2]}) do + sub_unit = subtract_power([power, unit], 1) + do_reduce_factors({[sub_unit | rest_1], rest_2}) end - def reduce_factors({[[:cubic, unit] | rest_1], [[:cubic, unit] | rest_2]}) do - # |> IO.inspect(label: "6") - reduce_factors({rest_1, rest_2}) + def do_reduce_factors({[unit | rest_1], [[power, unit] | rest_2]}) do + sub_unit = subtract_power([power, unit], 1) + do_reduce_factors({rest_1, [sub_unit | rest_2]}) end - def reduce_factors({[[:cubic, unit] | rest_1], [[:square, unit] | rest_2]}) do - # |> IO.inspect(label: "7") - reduce_factors({[unit | rest_1], rest_2}) + # Both units have powers so we subtract the denominator from the + # numerator. + def do_reduce_factors({[[power_1, unit] | rest_1], [[power_2, unit] | rest_2]}) do + {sub_unit_1, sub_unit_2} = subtract_power([power_1, unit], [power_2, unit]) + do_reduce_factors({[sub_unit_1 | rest_1], [sub_unit_2 | rest_2]}) end - def reduce_factors({[[:cubic, unit] | rest_1], [unit | rest_2]}) do - # |> IO.inspect(label: "8") - reduce_factors({[[:square, unit] | rest_1], rest_2}) - end + # No power units involved so we need to move along. + # THe list of units is always in a canonical order. + def do_reduce_factors({[unit_1 | rest_1], [unit_2 | rest_2]}) do + cond do + compare(unit_1, unit_2) == :lt -> + {reduced_1, reduced_2} = do_reduce_factors({rest_1, [unit_2 | rest_2]}) + {[unit_1 | reduced_1], reduced_2} - def reduce_factors({[unit_1 | rest_1], rest_2}) do - {numerator, denominator} = reduce_factors({rest_1, rest_2}) - # |> IO.inspect(label: "9") - {[unit_1 | numerator], denominator} + compare(unit_1, unit_2) == :gt -> + {reduced_1, reduced_2} = do_reduce_factors({[unit_1 | rest_1], rest_2}) + {reduced_1, [unit_2 | reduced_2]} + end end - def reduce_factors(other) do - # |> IO.inspect(label: "Other") - other + defp is_base_unit(unit) do + maybe_base_unit = String.to_existing_atom(unit) + maybe_base_unit in @inverted_base_units_name + rescue ArgumentError -> + false end # Reduce powers to square and cubic @@ -319,7 +358,8 @@ defmodule Cldr.Unit.BaseUnit do [first | reduce_powers(rest)] end - # Flaten the list and turn it into a string + # Flaten the list and turn it into a string. + defp flatten_and_stringify({[], denominator}) do flatten_and_stringify(denominator) end @@ -395,8 +435,10 @@ defmodule Cldr.Unit.BaseUnit do {tag, other} end - @base_units_in_order Cldr.Config.units() - |> Map.get(:base_units) + @units Cldr.Config.units() + @base_units @units[:base_units] + + @base_units_in_order @base_units |> Cldr.Unit.Additional.merge_base_units() |> Enum.map(&elem(&1, 1)) |> Enum.with_index() @@ -406,4 +448,25 @@ defmodule Cldr.Unit.BaseUnit do def base_units_in_order do @base_units_in_order end + + defp subtract_power([power, unit], number) when is_number(number) do + exponent = Prefix.power_units()[power] - number + power = Prefix.inverse_power_units()[exponent] + + if exponent == 1, do: unit, else: [power, unit] + end + + defp subtract_power([pow_1, unit], [pow_2, unit]) do + exp_1 = Prefix.power_units()[pow_1] + exp_2 = Prefix.power_units()[pow_2] + min = min(exp_1, exp_2) + + new_exp_1 = exp_1 - min + new_exp_2 = exp_2 - min + + new_unit_1 = if new_exp_1 == 1, do: unit, else: [new_exp_1, unit] + new_unit_2 = if new_exp_2 == 1, do: unit, else: [new_exp_2, unit] + + {new_unit_1, new_unit_2} + end end diff --git a/lib/cldr/unit/conversion.ex b/lib/cldr/unit/conversion.ex index edd5e15..b1bdd50 100644 --- a/lib/cldr/unit/conversion.ex +++ b/lib/cldr/unit/conversion.ex @@ -1,14 +1,15 @@ defmodule Cldr.Unit.Conversion do @moduledoc """ Unit conversion functions for the units defined - in `Cldr`. + in `CLDR`. """ - @enforce_keys [:factor, :offset, :base_unit] - defstruct factor: 1, - offset: 0, - base_unit: nil + @enforce_keys [:base_unit] + defstruct factor: nil, + offset: nil, + base_unit: nil, + special: nil @type factor :: integer | float @type offset :: integer | float @@ -16,7 +17,8 @@ defmodule Cldr.Unit.Conversion do @type t :: %{ factor: factor(), base_unit: [atom(), ...], - offset: offset() + offset: offset(), + special: atom() | nil } alias Cldr.Unit @@ -25,7 +27,6 @@ defmodule Cldr.Unit.Conversion do import Kernel, except: [div: 2] @decimal_1 Decimal.new(1) - @decimal_0 Decimal.new(0) @doc """ Returns the conversion that calculates @@ -94,11 +95,15 @@ defmodule Cldr.Unit.Conversion do ## Example iex> Cldr.Unit.Conversion.base_unit_and_conversion :square_kilometer - { - :ok, - :square_meter, - [square_kilometer: %Cldr.Unit.Conversion{base_unit: [:square, :meter], factor: 1000000, offset: 0}] - } + {:ok, :square_meter, + [ + {"square_kilometer", + %Cldr.Unit.Conversion{ + factor: 1000000, + offset: 0, + base_unit: [:square, :meter] + }} + ]} iex> Cldr.Unit.Conversion.base_unit_and_conversion :square_table {:error, {Cldr.UnknownUnitError, "Unknown unit was detected at \\"table\\""}} @@ -123,9 +128,9 @@ defmodule Cldr.Unit.Conversion do ## Arguments - * `unit` is any unit returned by `Cldr.Unit.new/2` + * `unit` is any unit returned by `Cldr.Unit.new/2`. - * `to_unit` is any unit name returned by `Cldr.Unit.known_units/0` + * `to_unit` is any unit name returned by `Cldr.Unit.known_units/0`. ## Returns @@ -167,6 +172,11 @@ defmodule Cldr.Unit.Conversion do value end + # Special handling for Beaufort + defp convert_to_base(value, {_, %__MODULE__{special: :beaufort}}) do + mult(0.836, pow(value, 1.5)) + end + # All conversions are ultimately a list of # 2-tuples of the unit and conversion struct defp convert_to_base(value, {_, %__MODULE__{} = from}) do @@ -201,6 +211,14 @@ defmodule Cldr.Unit.Conversion do raise ArgumentError, "Conversion not recognised: #{inspect(conversion)}" end + # Special handling for Beaufort + defp convert_from_base(value, {_, %__MODULE__{special: :beaufort}}) do + # B = (S/0.836)^(2/3) + divided = div(value, 0.836) + pow(divided, 2 / 3) + |> Cldr.Math.round(2) + end + defp convert_from_base(value, {_, %__MODULE__{} = to}) do %{factor: to_factor, offset: to_offset} = to @@ -230,13 +248,13 @@ defmodule Cldr.Unit.Conversion do @doc """ Convert one unit into another unit of the same unit type (length, volume, mass, ...) and raises - on a unit type mismatch + on a unit type mismatch. ## Arguments - * `unit` is any unit returned by `Cldr.Unit.new/2` + * `unit` is any unit returned by `Cldr.Unit.new/2`. - * `to_unit` is any unit name returned by `Cldr.Unit.known_units/0` + * `to_unit` is any unit name returned by `Cldr.Unit.known_units/0`. ## Returns @@ -310,7 +328,7 @@ defmodule Cldr.Unit.Conversion do @doc """ Convert a unit into its base unit and - raises on error + raises on error. For example, the base unit for `length` is `meter`. The base unit is an @@ -319,7 +337,7 @@ defmodule Cldr.Unit.Conversion do ## Arguments - * `unit` is any unit returned by `Cldr.Unit.new/2` + * `unit` is any unit returned by `Cldr.Unit.new/2`. ## Returns @@ -341,160 +359,19 @@ defmodule Cldr.Unit.Conversion do end end - #### Math helpers for Decimal and integer - + # Math Helpers @doc false - def add(any, 0) do - maybe_integer(any) - end - - def add(any, @decimal_0) do - maybe_integer(any) - end - - def add(%Decimal{} = a, b) do - Decimal.add(a, b) - |> maybe_integer() - end - - def add(a, %Decimal{} = b) do - Decimal.add(a, b) - |> maybe_integer() - end - - def add(a, b) do - maybe_integer(a + b) - end + def add(v1, v2), do: Cldr.Math.add(v1, v2) |> Cldr.Math.maybe_integer() @doc false - def sub(any, 0) do - maybe_integer(any) - end - - def sub(any, float) when float == 0.0 do - maybe_integer(any) - end - - def sub(a, %Decimal{} = b) do - Decimal.sub(a, b) - |> maybe_integer() - end - - def sub(%Decimal{} = a, b) do - Decimal.sub(a, b) - |> maybe_integer() - end - - def sub(a, b) do - maybe_integer(a - b) - end + def sub(v1, v2), do: Cldr.Math.sub(v1, v2) |> Cldr.Math.maybe_integer() @doc false - def mult(any, 1) do - any - end - - def mult(any, @decimal_1) do - any - end - - def mult(1, b) do - maybe_integer(b) - end - - def mult(_any, 0) do - 0 - end - - def mult(_any, @decimal_0) do - 0 - end - - def mult(%Decimal{} = a, b) do - Decimal.mult(a, b) - |> maybe_integer() - end - - def mult(a, %Decimal{} = b) do - Decimal.mult(a, b) - |> maybe_integer() - end - - def mult(a, b) do - (a * b) - |> maybe_integer() - end - - def div(_any, 0) do - 0 - end - - def div(_any, @decimal_0) do - 0 - end - - def div(any, 1) do - maybe_integer(any) - end - - def div(any, @decimal_1) do - maybe_integer(any) - end - - def div(%Decimal{} = a, b) do - Decimal.div(a, b) - |> maybe_integer() - end - - def div(a, %Decimal{} = b) do - Decimal.div(a, b) - |> maybe_integer() - end - - def div(a, b) when is_integer(a) and is_integer(b) do - integer_div = Kernel.div(a, b) - - if integer_div * b == a do - integer_div - else - Decimal.div(Decimal.new(a), Decimal.new(b)) - end - end + def mult(v1, v2), do: Cldr.Math.mult(v1, v2) |> Cldr.Math.maybe_integer() @doc false - def pow(_any, @decimal_0) do - 1 - end - - def pow(1, _any) do - 1 - end - - def pow(a, b) when is_integer(b) do - Cldr.Math.power(a, b) - |> maybe_integer - end - - # Decimal.integer? only on 2.x but we support 1.x - # so we have to check the hard way + def div(v1, v2), do: Cldr.Math.div(v1, v2) |> Cldr.Math.maybe_integer() - def maybe_integer(%Decimal{} = a) do - Decimal.to_integer(a) - rescue - FunctionClauseError -> - a - ArgumentError -> - a - end - - def maybe_integer(a) when is_float(a) do - case trunc(a) do - b when a == b -> b - _b -> a - end - end - - def maybe_integer(a) when is_integer(a) do - a - end + @doc false + def pow(v1, v2), do: Cldr.Math.pow(v1, v2) |> Cldr.Math.maybe_integer() end diff --git a/lib/cldr/unit/conversion/conversions.ex b/lib/cldr/unit/conversion/conversions.ex index f26beac..1bfff5d 100644 --- a/lib/cldr/unit/conversion/conversions.ex +++ b/lib/cldr/unit/conversion/conversions.ex @@ -10,6 +10,9 @@ defmodule Cldr.Unit.Conversions do {k, v} -> {k, struct(Conversion, v)} end) |> Enum.map(fn + {unit, %{special: special} = conversion} when not is_nil(special) -> + {unit, conversion} + {unit, %{factor: factor} = conversion} when is_number(factor) -> {unit, conversion} @@ -20,6 +23,9 @@ defmodule Cldr.Unit.Conversions do {unit, %{conversion | factor: Decimal.div(factor.numerator, factor.denominator)}} end) |> Enum.map(fn + {unit, %{special: special} = conversion} when not is_nil(special) -> + {unit, conversion} + {unit, %{offset: offset} = conversion} when is_number(offset) -> {unit, conversion} diff --git a/lib/cldr/unit/format.ex b/lib/cldr/unit/format.ex index 1b20dc8..4c133d8 100644 --- a/lib/cldr/unit/format.ex +++ b/lib/cldr/unit/format.ex @@ -20,7 +20,7 @@ defmodule Cldr.Unit.Format do @typep grammar_list :: [grammar, ...] - @translatable_units Cldr.Unit.known_units() + @known_units Cldr.Unit.known_units() @si_keys Cldr.Unit.Prefix.si_keys() @binary_keys Cldr.Unit.Prefix.binary_keys() @power_keys Cldr.Unit.Prefix.power_keys() @@ -128,7 +128,7 @@ defmodule Cldr.Unit.Format do {:ok, "1,234 megahertz"} iex> Cldr.Unit.Format.to_string Cldr.Unit.new!(:megahertz, 1234), MyApp.Cldr, style: :narrow - {:ok, "1,234MHz"} + {:ok, "1,234Mhz"} iex> {:ok, range} = Cldr.Unit.Range.new(Cldr.Unit.new!(:gram, 1), Cldr.Unit.new!(:gram, 5)) iex> Cldr.Unit.to_string(range, locale: :ja) @@ -432,7 +432,7 @@ defmodule Cldr.Unit.Format do end # Direct formatting of the unit since it is translatable directly - def to_iolist(%Cldr.Unit{unit: name} = unit, backend, options) when name in @translatable_units do + def to_iolist(%Cldr.Unit{unit: name} = unit, backend, options) when name in @known_units do with {:ok, options} <- normalize_options(backend, options) do options = extract_options!(unit, options) unit_grammar = {name, {options.grammatical_case, options.plural}} @@ -498,7 +498,7 @@ defmodule Cldr.Unit.Format do # It's a Cldr.Unit.Range for a basic unit def to_iolist(%{first: %{value: v1}, last: %{unit: name, value: v2} = last}, backend, options) - when name in @translatable_units do + when name in @known_units do with {:ok, options} <- normalize_options(backend, options) do options = extract_options!(last, options) unit_grammar = {name, {options.grammatical_case, options.plural}} @@ -1231,11 +1231,12 @@ defmodule Cldr.Unit.Format do @si_prefix Cldr.Unit.Prefix.si_power_prefixes() @binary_prefix Cldr.Unit.Prefix.binary_prefixes() - @power Cldr.Unit.Prefix.power_units() |> Map.new() + @power Cldr.Unit.Prefix.power_units() # String decomposition for {power, exp} <- @power do power_unit = String.to_atom("power#{exp}") + power = to_string(power) defp do_traverse(unquote(power) <> "_" <> unit, fun) do fun.({:power, {fun.({:unit, unquote(power_unit)}), do_traverse(unit, fun)}}) diff --git a/lib/cldr/unit/math.ex b/lib/cldr/unit/math.ex index 08c489d..6215ff1 100644 --- a/lib/cldr/unit/math.ex +++ b/lib/cldr/unit/math.ex @@ -10,6 +10,8 @@ defmodule Cldr.Unit.Math do import Kernel, except: [div: 2, round: 1, trunc: 1] import Unit, only: [incompatible_units_error: 2] + @type rounding_mode :: :down | :up | :ceiling | :floor | :half_even | :half_up | :half_down + @doc false defguard is_per_unit(base_conversion) when is_tuple(base_conversion) and @@ -158,14 +160,18 @@ defmodule Cldr.Unit.Math do end @doc """ - Multiplies two `t:Cldr.Unit.t/0` types. Any two - units can be multiplied together. + Multiplies any two `t:Cldr.Unit.t/0` types or a t:Cldr.Unit.t/0` + and a scalar. ## Arguments - * `unit_1` and `unit_2` are Units + * `unit_1` is a unit returned by `Cldr.Unit.new/2`. + * `unit_2` is a unit + returned by `Cldr.Unit.new/2` or + a number or Decimal. + ## Returns * A `t:Cldr.Unit.t/0` of a type that is the product @@ -191,6 +197,14 @@ defmodule Cldr.Unit.Math do Unit.new!(unit, Conversion.mult(value_1, value_2)) end + def mult(%Unit{value: value} = unit, number) when is_number(number) do + %{unit | value: Conversion.mult(value, number)} + end + + def mult(%Unit{value: value} = unit, %Decimal{} = number) do + %{unit | value: Conversion.mult(value, number)} + end + def mult(%Unit{unit: unit_category_1} = unit_1, %Unit{unit: unit_category_2} = unit_2) do if Unit.compatible?(unit_category_1, unit_category_2) do {:ok, converted} = Conversion.convert(unit_2, unit_category_1) @@ -200,15 +214,20 @@ defmodule Cldr.Unit.Math do end end + @doc """ Multiplies two compatible `t:Cldr.Unit.t/0` types and raises on error. ## Options - * `unit_1` and `unit_2` are compatible Units + * `unit_1` is a unit returned by `Cldr.Unit.new/2`. + * `unit_2` is a unit + returned by `Cldr.Unit.new/2` or + a number or Decimal. + ## Returns * A `t:Cldr.Unit.t/0` of the same type as `unit_1` with a value @@ -225,13 +244,17 @@ defmodule Cldr.Unit.Math do end @doc """ - Divides one `t:Cldr.Unit.t/0` type into another. - Any unit can be divided by another. + Divides any `t:Cldr.Unit.t/0` type into another or a + number into a `t:Cldr.Unit.t/0`. ## Options - * `unit_1` and `unit_2` are Units - returned by `Cldr.Unit.new/2` + * `unit_1` is a unit + returned by `Cldr.Unit.new/2`. + + * `unit_2` is a unit + returned by `Cldr.Unit.new/2` or + a number or Decimal. ## Returns @@ -258,6 +281,14 @@ defmodule Cldr.Unit.Math do Unit.new!(unit, Conversion.div(value_1, value_2)) end + def div(%Unit{value: value} = unit, number) when is_number(number) do + %{unit | value: Conversion.div(value, number)} + end + + def div(%Unit{value: value} = unit, %Decimal{} = number) do + %{unit | value: Conversion.div(value, number)} + end + def div(%Unit{unit: unit_category_1} = unit_1, %Unit{unit: unit_category_2} = unit_2) do if Unit.compatible?(unit_category_1, unit_category_2) do div(unit_1, Conversion.convert!(unit_2, unit_category_1)) @@ -272,8 +303,12 @@ defmodule Cldr.Unit.Math do ## Arguments - * `unit_1` and `unit_2` are compatible Units - returned by `Cldr.Unit.new/2` + * `unit_1` is a unit + returned by `Cldr.Unit.new/2`. + + * `unit_2` is a unit + returned by `Cldr.Unit.new/2` or + a number or Decimal. ## Returns @@ -346,23 +381,31 @@ defmodule Cldr.Unit.Math do """ @spec round( - unit :: Unit.t(), + unit :: Unit.t() | number() | Decimal.t(), places :: non_neg_integer, - mode :: :down | :up | :ceiling | :floor | :half_even | :half_up | :half_down - ) :: Unit.t() + mode :: rounding_mode() + ) :: Unit.t() | number() | Decimal.t() def round(unit, places \\ 0, mode \\ :half_up) - # def round(%Unit{value: %Ratio{} = value} = unit, places, mode) do - # value = Ratio.to_float(value) - # round(%{unit | value: value}, places, mode) - # end + def round(value, _places, _mode) when is_integer(value) do + value + end + + def round(value, places, mode) when is_float(value) do + Cldr.Math.round(value, places, mode) + |> Cldr.Math.maybe_integer() + end + + def round(%Decimal{} = value, places, mode) do + Decimal.round(value, places, mode) + |> Cldr.Math.maybe_integer() + end def round(%Unit{value: value} = unit_1, places, mode) do rounded_value = value - |> Cldr.Math.round(places, mode) - |> Conversion.maybe_integer() + |> round(places, mode) %{unit_1 | value: rounded_value} end @@ -372,11 +415,6 @@ defmodule Cldr.Unit.Math do """ - # def trunc(%Unit{value: %Ratio{} = value} = unit) do - # value = Ratio.to_float(value) - # trunc(%{unit | value: value}) - # end - def trunc(%Unit{value: value} = unit) when is_float(value) do %{unit | value: Kernel.trunc(value)} end diff --git a/lib/cldr/unit/parser.ex b/lib/cldr/unit/parser.ex index 75e1648..a1aa98f 100644 --- a/lib/cldr/unit/parser.ex +++ b/lib/cldr/unit/parser.ex @@ -301,7 +301,7 @@ defmodule Cldr.Unit.Parser do # # 1. Replace any aliases # - # 2. Ignore "square" and "cubic" prefixes, they + # 2. Ignore "square", "cubic" and "pown" prefixes, they # are just passed through for later use # # 3. For each known unit, defined as a key on @@ -339,6 +339,8 @@ defmodule Cldr.Unit.Parser do end for {prefix, _power} <- Prefix.power_units() do + prefix = to_string(prefix) + def split_into_units(< "_", rest::binary>>) do [unquote(prefix) | split_into_units(rest)] end @@ -394,6 +396,8 @@ defmodule Cldr.Unit.Parser do end for {prefix, power} <- Prefix.power_units() do + prefix = to_string(prefix) + defp expand_power_instances([unquote(prefix), unit | rest]) do List.duplicate(unit, unquote(power)) ++ expand_power_instances(rest) end @@ -408,7 +412,7 @@ defmodule Cldr.Unit.Parser do end # Reassemble the power units by grouping and - # combining with a square or cubic prefix + # combining with a square, cubic or pown prefix # if there is more than one instance defp combine_power_instances(units) do @@ -425,11 +429,7 @@ defmodule Cldr.Unit.Parser do "cubic_#{k}" {k, v} -> - raise( - Cldr.UnknownUnitError, - "Unable to parse more than square and cubic powers. The requested unit " <> - "would require a base unit of #{inspect(k)} to the power of #{length(v)}" - ) + "pow#{length(v)}_#{k}" end) end @@ -442,14 +442,23 @@ defmodule Cldr.Unit.Parser do # kilogram is special since its the base unit for mass # but also has an SI prefix. We want to keep the original # conversion - not calculate it. + defp resolve_base_unit("kilogram" = unit) do hd(Conversions.conversion_for!(unit)) end + defp resolve_base_unit("kilowatt_hour" = unit) do + hd(Conversions.conversion_for!(unit)) + end + + defp resolve_base_unit("kilogram_force" = unit) do + hd(Conversions.conversion_for!(unit)) + end + for {prefix, scale} <- Prefix.si_factors() do defp resolve_base_unit(<> = unit) do with {_, conversion} <- resolve_base_unit(base_unit) do - factor = Conversion.mult(conversion.factor, unquote(Macro.escape(scale))) + factor = Cldr.Math.mult(conversion.factor, unquote(Macro.escape(scale))) {Unit.maybe_translatable_unit(unit), %{conversion | factor: factor}} else {:error, {exception, reason}} -> raise(exception, reason) @@ -460,7 +469,7 @@ defmodule Cldr.Unit.Parser do for {prefix, scale} <- Prefix.binary_factors() do defp resolve_base_unit(<> = unit) do with {_, conversion} <- resolve_base_unit(base_unit) do - factor = Conversion.mult(conversion.factor, unquote(Macro.escape(scale))) + factor = Cldr.Math.mult(conversion.factor, unquote(Macro.escape(scale))) {Unit.maybe_translatable_unit(unit), %{conversion | factor: factor}} else {:error, {exception, reason}} -> raise(exception, reason) @@ -469,9 +478,11 @@ defmodule Cldr.Unit.Parser do end for {prefix, power} <- Prefix.power_units() do + prefix = to_string(prefix) + defp resolve_base_unit(< "_", subunit::binary>> = unit) do with {_, conversion} <- resolve_base_unit(subunit) do - factor = Conversion.pow(conversion.factor, unquote(power)) + factor = Cldr.Math.pow(conversion.factor, unquote(power)) base_unit = [String.to_atom(unquote(prefix)) | conversion.base_unit] {Unit.maybe_translatable_unit(unit), %{conversion | base_unit: base_unit, factor: factor}} else @@ -498,7 +509,7 @@ defmodule Cldr.Unit.Parser do defp resolve_base_unit({integer, unit}) do {name, unit} = resolve_base_unit(unit) name = "#{integer}_#{name}" - factor = Conversion.mult(unit.factor, integer) + factor = Cldr.Math.mult(unit.factor, integer) {name, %{unit | factor: factor}} end @@ -525,6 +536,8 @@ defmodule Cldr.Unit.Parser do end for {prefix, _power} <- Prefix.power_units() do + prefix = to_string(prefix) + defp unit_sort_key({< "_", unit::binary>>, conversion}) do unit_sort_key({unit, conversion}) end diff --git a/lib/cldr/unit/prefix.ex b/lib/cldr/unit/prefix.ex index ccc01a0..39d1476 100644 --- a/lib/cldr/unit/prefix.ex +++ b/lib/cldr/unit/prefix.ex @@ -1,32 +1,27 @@ defmodule Cldr.Unit.Prefix do @moduledoc false - @si_factors %{ - "quecto" => Decimal.div(1, 1_000_000_000_000_000_000_000_000_000_000), - "ronto" => Decimal.div(1, 1_000_000_000_000_000_000_000_000_000), - "yokto" => Decimal.div(1, 1_000_000_000_000_000_000_000_000), - "zepto" => Decimal.div(1, 1_000_000_000_000_000_000_000), - "atto" => Decimal.div(1, 1_000_000_000_000_000_000), - "femto" => Decimal.div(1, 1_000_000_000_000_000), - "pico" => Decimal.div(1, 1_000_000_000_000), - "nano" => Decimal.div(1, 1_000_000_000), - "micro" => Decimal.div(1, 1_000_000), - "milli" => Decimal.div(1, 1_000), - "centi" => Decimal.div(1, 100), - "deci" => Decimal.div(1, 10), - "deka" => 10, - "hecto" => 100, - "kilo" => 1_000, - "mega" => 1_000_000, - "giga" => 1_000_000_000, - "tera" => 1_000_000_000_000, - "peta" => 1_000_000_000_000_000, - "exa" => 1_000_000_000_000_000_000, - "zetta" => 1_000_000_000_000_000_000_000, - "yotta" => 1_000_000_000_000_000_000_000_000, - "ronna" => 1_000_000_000_000_000_000_000_000_000, - "quetta" => 1_000_000_000_000_000_000_000_000_000_000 - } + @units Cldr.Config.units() + + ## + ## SI prefixes + ## + + @si_factors @units + |> Map.fetch!(:prefixes) + |> Enum.reduce([], fn + {prefix, %{base: 10 = base, power: power}}, acc -> + abs_factor = Cldr.Math.power(base, abs(power)) + + factor = + if power < 0, do: Decimal.div(1, abs_factor), else: abs_factor + + [{to_string(prefix), factor} | acc] + + _other, acc -> + acc + end) + |> Map.new() def si_factors do @si_factors @@ -72,12 +67,30 @@ defmodule Cldr.Unit.Prefix do ## Power prefixes ## - @power_units [{"square", 2}, {"cubic", 3}, {"pow4", 4}] + @power_units @units + |> Map.fetch!(:components) + |> Map.fetch!(:power) + |> Enum.with_index(2) + |> Enum.map(fn {k, v} -> + v = if v > 3, do: v - 2, else: v + {String.to_atom(k), v} + end) + |> Map.new() def power_units do @power_units end + @inverse_power_units @power_units + |> Enum.map(fn {k, v} -> {v, k} end) + |> Map.new() + |> Map.put(2, :square) + |> Map.put(3, :cubic) + + def inverse_power_units do + @inverse_power_units + end + @power_keys @power_units |> Enum.map(fn {_name, exp} -> String.to_atom("power#{exp}") @@ -91,16 +104,18 @@ defmodule Cldr.Unit.Prefix do ## Binary prefixes, 1024 ^ x where 1 <= x <= 8 ## - @binary_factors %{ - "kibi" => 1_024, - "mebi" => 2_048, - "gibi" => 4_096, - "tebi" => 8_192, - "pebi" => 16_384, - "exbi" => 32_768, - "zebi" => 65_536, - "yobi" => 131_072 - } + @binary_factors @units + |> Map.fetch!(:prefixes) + |> Enum.reduce([], fn + {prefix, %{base: 2 = base, power: power}}, acc -> + factor = Cldr.Math.power(base, power) + + [{to_string(prefix), factor} | acc] + + _other, acc -> + acc + end) + |> Map.new() def binary_factors do @binary_factors @@ -108,7 +123,7 @@ defmodule Cldr.Unit.Prefix do @binary_keys @binary_factors |> Enum.map(fn {_name, exp} -> - exp = trunc(:math.log2(exp)) - 9 + exp = trunc(:math.log2(exp) / 10) String.to_atom("1024p#{exp}") end) @@ -119,7 +134,7 @@ defmodule Cldr.Unit.Prefix do @binary_prefixes @binary_factors |> Enum.map(fn {prefix, factor} when is_integer(factor) -> - {prefix, trunc(:math.log2(factor)) - 9} + {prefix, trunc(:math.log2(factor) / 10)} end) |> Map.new() @@ -142,7 +157,7 @@ defmodule Cldr.Unit.Prefix do @prefixes Enum.sort(Map.keys(@si_factors)) ++ Enum.sort(Map.keys(@binary_factors)) ++ - Enum.map(@power_units, fn {factor, _} -> factor <> "_" end) + Enum.map(@power_units, fn {factor, _} -> to_string(factor) <> "_" end) def prefixes do @prefixes diff --git a/mix.exs b/mix.exs index 6ebe0f6..65b3849 100644 --- a/mix.exs +++ b/mix.exs @@ -1,7 +1,7 @@ defmodule Cldr.Units.Mixfile do use Mix.Project - @version "3.16.5" + @version "3.17.0" def project do [ @@ -39,10 +39,14 @@ defmodule Cldr.Units.Mixfile do defp deps do [ - {:ex_cldr_numbers, "~> 2.31"}, - {:cldr_utils, "~> 2.24"}, + # {:ex_cldr_numbers, path: "../cldr_numbers", override: true}, + {:ex_cldr_numbers, "~> 2.33.0"}, + + # {:cldr_utils, path: "../cldr_utils", override: true}, + {:cldr_utils, "~> 2.25"}, {:ex_cldr_lists, "~> 2.10"}, + {:decimal, "~> 1.6 or ~> 2.0"}, {:dialyxir, "~> 1.0", only: [:dev, :test], runtime: false}, {:ex_doc, "~> 0.18", optional: true, runtime: false}, diff --git a/mix.lock b/mix.lock index 9c3f5b7..7901d13 100644 --- a/mix.lock +++ b/mix.lock @@ -7,11 +7,11 @@ "digital_token": {:hex, :digital_token, "0.6.0", "13e6de581f0b1f6c686f7c7d12ab11a84a7b22fa79adeb4b50eec1a2d278d258", [:mix], [{:cldr_utils, "~> 2.17", [hex: :cldr_utils, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "2455d626e7c61a128b02a4a8caddb092548c3eb613ac6f6a85e4cbb6caddc4d1"}, "earmark_parser": {:hex, :earmark_parser, "1.4.39", "424642f8335b05bb9eb611aa1564c148a8ee35c9c8a8bba6e129d51a3e3c6769", [:mix], [], "hexpm", "06553a88d1f1846da9ef066b87b57c6f605552cfbe40d20bd8d59cc6bde41944"}, "erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"}, - "ex_cldr": {:hex, :ex_cldr, "2.37.5", "9da6d97334035b961d2c2de167dc6af8cd3e09859301a5b8f49f90bd8b034593", [:mix], [{:cldr_utils, "~> 2.21", [hex: :cldr_utils, repo: "hexpm", optional: false]}, {:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:gettext, "~> 0.19", [hex: :gettext, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: true]}], "hexpm", "74ad5ddff791112ce4156382e171a5f5d3766af9d5c4675e0571f081fe136479"}, - "ex_cldr_currencies": {:hex, :ex_cldr_currencies, "2.15.1", "e92ba17c41e7405b7784e0e65f406b5f17cfe313e0e70de9befd653e12854822", [:mix], [{:ex_cldr, "~> 2.34", [hex: :ex_cldr, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "31df8bd37688340f8819bdd770eb17d659652078d34db632b85d4a32864d6a25"}, + "ex_cldr": {:hex, :ex_cldr, "2.38.0", "80399ccbfd996ea02f245394db83d7ce6113ed88e1e50e4695238cd9a0c258d5", [:mix], [{:cldr_utils, "~> 2.25", [hex: :cldr_utils, repo: "hexpm", optional: false]}, {:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:gettext, "~> 0.19", [hex: :gettext, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: true]}], "hexpm", "8758000c97bdf4b2583c3fedd7cfa35896567a7f8351248b2faa33ba73841cc7"}, + "ex_cldr_currencies": {:hex, :ex_cldr_currencies, "2.16.0", "fb62b5ed735427989a2b1c0f7089ed08d8387666cc59b8257f2376d1a39e5a2d", [:mix], [{:ex_cldr, "~> 2.38", [hex: :ex_cldr, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "7b1cc81605fa7023d896430d2ead36adb6abe13d09573500cba130824e10baf0"}, "ex_cldr_lists": {:hex, :ex_cldr_lists, "2.11.0", "1d39e75f0e493ccc95adfc85c55b4ca34f0771626350ce326d9ab8813d91444e", [:mix], [{:ex_cldr_numbers, "~> 2.25", [hex: :ex_cldr_numbers, repo: "hexpm", optional: false]}, {:ex_doc, "~> 0.18", [hex: :ex_doc, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "8132b30a5506ae8a09e5c9a21c23fd60c8837ce6c3a1de9966d813eb78951695"}, - "ex_cldr_numbers": {:hex, :ex_cldr_numbers, "2.32.4", "5562148dfc631b04712983975093d2aac29df30b3bf2f7257e0c94b85b72e91b", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:digital_token, "~> 0.3 or ~> 1.0", [hex: :digital_token, repo: "hexpm", optional: false]}, {:ex_cldr, "~> 2.37", [hex: :ex_cldr, repo: "hexpm", optional: false]}, {:ex_cldr_currencies, ">= 2.14.2", [hex: :ex_cldr_currencies, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "6fd5a82f0785418fa8b698c0be2b1845dff92b77f1b3172c763d37868fb503d2"}, - "ex_doc": {:hex, :ex_doc, "0.31.2", "8b06d0a5ac69e1a54df35519c951f1f44a7b7ca9a5bb7a260cd8a174d6322ece", [:mix], [{:earmark_parser, "~> 1.4.39", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.1", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "317346c14febaba9ca40fd97b5b5919f7751fb85d399cc8e7e8872049f37e0af"}, + "ex_cldr_numbers": {:hex, :ex_cldr_numbers, "2.33.0", "e486f8c1e514384ea1f4c0cfb54ff508cf06e03aadf696976ec5d3698c2b9cb5", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:digital_token, "~> 0.3 or ~> 1.0", [hex: :digital_token, repo: "hexpm", optional: false]}, {:ex_cldr, "~> 2.38", [hex: :ex_cldr, repo: "hexpm", optional: false]}, {:ex_cldr_currencies, "~> 2.16", [hex: :ex_cldr_currencies, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "cab4685b2ff0795af21ba2cfe892af2cf28dbb87be3c6275bb499c5c1073e98d"}, + "ex_doc": {:hex, :ex_doc, "0.32.1", "21e40f939515373bcdc9cffe65f3b3543f05015ac6c3d01d991874129d173420", [:mix], [{:earmark_parser, "~> 1.4.39", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.1", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "5142c9db521f106d61ff33250f779807ed2a88620e472ac95dc7d59c380113da"}, "jason": {:hex, :jason, "1.4.1", "af1504e35f629ddcdd6addb3513c3853991f694921b1b9368b0bd32beb9f1b63", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "fbb01ecdfd565b56261302f7e1fcc27c4fb8f32d56eab74db621fc154604a7a1"}, "makeup": {:hex, :makeup, "1.1.1", "fa0bc768698053b2b3869fa8a62616501ff9d11a562f3ce39580d60860c3a55e", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "5dc62fbdd0de44de194898b6710692490be74baa02d9d108bc29f007783b0b48"}, "makeup_elixir": {:hex, :makeup_elixir, "0.16.2", "627e84b8e8bf22e60a2579dad15067c755531fea049ae26ef1020cad58fe9578", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "41193978704763f6bbe6cc2758b84909e62984c7752b3784bd3c218bb341706b"}, diff --git a/test/cldr_units_test.exs b/test/cldr_units_test.exs index 5dac1ec..99e7626 100644 --- a/test/cldr_units_test.exs +++ b/test/cldr_units_test.exs @@ -181,15 +181,15 @@ defmodule Cldr.UnitsTest do end test "create a unit that is directly translatable but has no explicit conversion" do - assert {:ok, "1 kilowatt hour"} == + assert {:ok, "1 kilowatt-hour"} == Cldr.Unit.new!(1, :kilowatt_hour) |> Cldr.Unit.Format.to_string() - assert {:ok, "1 Kilowattstunde"} == + assert {:ok, "1 Kilowatt⋅Stunde"} == Cldr.Unit.new!(1, :kilowatt_hour) |> Cldr.Unit.Format.to_string(locale: "de") end test "that a translatable unit name in binary form gets identified as translatable" do - assert {:ok, "1 kilowatt hour"} == + assert {:ok, "1 kilowatt-hour"} == Cldr.Unit.new!(1, "kilowatt_hour") |> Cldr.Unit.Format.to_string() end diff --git a/test/conversion_test.exs b/test/conversion_test.exs index 44c72eb..04f49c6 100644 --- a/test/conversion_test.exs +++ b/test/conversion_test.exs @@ -11,10 +11,10 @@ defmodule Cldr.Unit.Conversion.Test do end end - # Test #187 is reduced in rounding by one digit - # in order for the match to work. + # Test 185 is a Beaufort conversion. That needs special handling we + # don't have yet. And the test case data is unexpected. - @just_outside_tolerance [] + @just_outside_tolerance [185] for t <- ConversionData.conversions(), t.line not in @just_outside_tolerance do test "##{t.line} [Float] that #{t.from} converted to #{t.to} is #{inspect(t.result)}" do @@ -35,7 +35,7 @@ defmodule Cldr.Unit.Conversion.Test do end end - @just_outside_tolerance_decimal [] + @just_outside_tolerance_decimal [185] @one_thousand Decimal.new(1000) for t <- ConversionData.conversions(), t.line not in @just_outside_tolerance_decimal do @@ -79,4 +79,13 @@ defmodule Cldr.Unit.Conversion.Test do test "conversion where base units don't match but unit categories do" do assert {:ok, _} = Cldr.Unit.convert(Cldr.Unit.new!(:joule, 1), "kilowatt_hour") end + + test "converting from/to beaufort" do + beaufort = Cldr.Unit.new!(:beaufort, 17) + meter_per_second = Cldr.Unit.convert!(beaufort, :meter_per_second) |> Cldr.Unit.Math.round(1) + beaufort_2 = Cldr.Unit.convert!(meter_per_second, :beaufort) |> Cldr.Unit.Math.round(0) + + assert meter_per_second == Cldr.Unit.new!(:meter_per_second, "58.6") + assert beaufort_2 == Cldr.Unit.new!(:beaufort, 17) + end end diff --git a/test/measurement_systems_test.exs b/test/measurement_systems_test.exs index e511687..eb8da40 100644 --- a/test/measurement_systems_test.exs +++ b/test/measurement_systems_test.exs @@ -24,11 +24,11 @@ defmodule Cldr.Unit.MeasurementSystemTest do end test "Measurement systems for a unit" do - assert Cldr.Unit.measurement_systems_for_unit(:hectare) == [:metric] - assert Cldr.Unit.measurement_systems_for_unit(:liter) == [:metric] - assert Cldr.Unit.measurement_systems_for_unit("liter") == [:metric] - assert Cldr.Unit.measurement_systems_for_unit("liter_per_kilometer") == [:metric] - assert Cldr.Unit.measurement_systems_for_unit("acre_foot") == [:ussystem, :uksystem] + assert Cldr.Unit.measurement_systems_for_unit(:hectare) == [:metric, :si_acceptable] + assert Cldr.Unit.measurement_systems_for_unit(:liter) == [:metric, :prefixable, :si_acceptable] + assert Cldr.Unit.measurement_systems_for_unit("liter") == [:metric, :prefixable, :si_acceptable] + assert Cldr.Unit.measurement_systems_for_unit("liter_per_kilometer") == [:metric, :prefixable, :si_acceptable] + assert Cldr.Unit.measurement_systems_for_unit("acre_foot") == [:uksystem, :ussystem] assert Cldr.Unit.measurement_systems_for_unit(:litdf) == {:error, {Cldr.UnknownUnitError, "The unit :litdf is not known."}} @@ -43,12 +43,21 @@ defmodule Cldr.Unit.MeasurementSystemTest do {:error, {Cldr.UnknownUnitError, "The unit :litdf is not known."}} end - test "All known units resolve measurement systems" do + test "All known units (except :unit) resolve measurement systems" do errors = Cldr.Unit.known_units() - |> Enum.map(&Cldr.Unit.measurement_systems_for_unit/1) + |> Kernel.--([:unit]) + |> Enum.map(fn unit -> + Cldr.Unit.measurement_systems_for_unit(unit) + end) |> Enum.filter(fn i -> if is_list(i), do: false, else: true end) assert errors == [] end + + test "That measurement systems for :unit returns an error" do + assert Cldr.Unit.measurement_systems_for_unit(:unit) == + {:error, {Cldr.Unit.UnknownMeasurementSystemError, "The measurement systems for \"unit\" are not known"}} + end + end diff --git a/test/preference_test.exs b/test/preference_test.exs index 3796f73..c92777e 100644 --- a/test/preference_test.exs +++ b/test/preference_test.exs @@ -3,7 +3,7 @@ defmodule Cldr.Unit.Preference.Test do alias Cldr.Unit.Test.PreferenceData - @maybe_data_bugs [19, 397, 409, 413, 419] + @maybe_data_bugs [] for t <- PreferenceData.preferences(), t.line not in @maybe_data_bugs do diff --git a/test/support/data/conversion_test_data.txt b/test/support/data/conversion_test_data.txt index 2e82027..5b41e86 100644 --- a/test/support/data/conversion_test_data.txt +++ b/test/support/data/conversion_test_data.txt @@ -1,7 +1,7 @@ # Test data for unit conversions -# Copyright © 1991-2023 Unicode, Inc. +# Copyright © 1991-2024 Unicode, Inc. # For terms of use, see http://www.unicode.org/copyright.html -# SPDX-License-Identifier: Unicode-DFS-2016 +# SPDX-License-Identifier: Unicode-3.0 # CLDR data files are interpreted according to the LDML specification (http://unicode.org/reports/tr35/) # # Format: @@ -12,32 +12,36 @@ # round to 4 decimal digits before comparing. # Note that certain conversions are approximate, such as degrees to radians # -# Generation: Set GENERATE_TESTS in TestUnits.java, and look at TestParseUnit results. +# Generation: Set GENERATE_TESTS in TestUnits.java to regenerate unitsTest.txt. acceleration ; meter-per-square-second ; meter-per-square-second ; 1 * x ; 1,000.00 acceleration ; g-force ; meter-per-square-second ; 9.80665 * x ; 9806.65 angle ; arc-second ; revolution ; 0.0000625/81 * x ; 7.716049E-4 angle ; arc-minute ; revolution ; 0.00125/27 * x ; 0.0462963 angle ; degree ; revolution ; 0.025/9 * x ; 2.777778 -angle ; radian ; revolution ; 65,501,488/411,557,987 * x ; 159.1549 +angle ; radian ; revolution ; 65,501,488/411557987 * x ; 159.1549 angle ; revolution ; revolution ; 1 * x ; 1,000.00 area ; square-centimeter ; square-meter ; 0.0001 * x ; 0.1 area ; square-inch ; square-meter ; 0.00064516 * x ; 0.64516 area ; square-foot ; square-meter ; 0.09290304 * x ; 92.90304 area ; square-yard ; square-meter ; 0.83612736 * x ; 836.1274 area ; square-meter ; square-meter ; 1 * x ; 1,000.00 +area ; bu-jp ; square-meter ; 400/121 * x ; 3305.785 +area ; se-jp ; square-meter ; 12,000/121 * x ; 99173.55 area ; dunam ; square-meter ; 1,000 * x ; 1000000.0 area ; acre ; square-meter ; 4,046.8564224 * x ; 4046856.0 +area ; cho ; square-meter ; 1,200,000/121 * x ; 9917355.0 area ; hectare ; square-meter ; 10,000 * x ; 1.0E7 area ; square-kilometer ; square-meter ; 1,000,000 * x ; 1.0E9 area ; square-mile ; square-meter ; 2,589,988.110336 * x ; 2.589988E9 -concentration ; milligram-ofglucose-per-deciliter ; kilogram-item-per-kilogram-cubic-meter ; 60,221,407,600,000,000,000,000,000,000/1,801,557 * x ; 3.342742E25 +catalytic-activity ; katal ; item-per-second ; 602,214,076,000,000,000,000,000 * x ; 6.022141E26 +concentration ; milligram-ofglucose-per-deciliter ; kilogram-item-per-kilogram-cubic-meter ; 60,221,407,600,000,000,000,000,000,000/1801557 * x ; 3.342742E25 concentration ; millimole-per-liter ; item-per-cubic-meter ; 602,214,076,000,000,000,000,000 * x ; 6.022141E26 -concentration-mass ; ofglucose ; item-per-kilogram ; 6,022,140,760,000,000,000,000,000,000,000/1,801,557 * x ; 3.342742E27 +concentration-mass ; ofglucose ; item-per-kilogram ; 6,022,140,760,000,000,000,000,000,000,000/1801557 * x ; 3.342742E27 consumption ; liter-per-100-kilometer ; cubic-meter-per-meter ; 0.00000001 * x ; 1.0E-5 consumption ; liter-per-kilometer ; cubic-meter-per-meter ; 0.000001 * x ; 0.001 -consumption-inverse ; mile-per-gallon-imperial ; meter-per-cubic-meter ; 160,934,400,000/454,609 * x ; 3.540062E8 -consumption-inverse ; mile-per-gallon ; meter-per-cubic-meter ; 48,000,000,000/112,903 * x ; 4.251437E8 +consumption-inverse ; mile-per-gallon-imperial ; meter-per-cubic-meter ; 160,934,400,000/454609 * x ; 3.540062E8 +consumption-inverse ; mile-per-gallon ; meter-per-cubic-meter ; 48,000,000,000/112903 * x ; 4.251437E8 digital ; bit ; bit ; 1 * x ; 1,000.00 digital ; byte ; bit ; 8 * x ; 8000.0 digital ; kilobit ; bit ; 1,000 * x ; 1000000.0 @@ -59,23 +63,30 @@ duration ; day ; second ; 86,400 * x ; 8.64E7 duration ; day-person ; second ; 86,400 * x ; 8.64E7 duration ; week ; second ; 604,800 * x ; 6.048E8 duration ; week-person ; second ; 604,800 * x ; 6.048E8 +duration ; fortnight ; second ; 1,209,600 * x ; 1.2096E9 +electric-capacitance ; farad ; pow4-second-square-ampere-per-kilogram-square-meter ; 1 * x ; 1000.0 +electric-charge ; coulomb ; second-ampere ; 1 * x ; 1000.0 +electric-conductance ; siemens ; cubic-second-square-ampere-per-kilogram-square-meter ; 1 * x ; 1000.0 electric-current ; milliampere ; ampere ; 0.001 * x ; 1.0 electric-current ; ampere ; ampere ; 1 * x ; 1,000.00 +electric-inductance ; henry ; kilogram-square-meter-per-square-second-square-ampere ; 1 * x ; 1000.0 electric-resistance ; ohm ; kilogram-square-meter-per-cubic-second-square-ampere ; 1 * x ; 1000.0 energy ; electronvolt ; kilogram-square-meter-per-square-second ; 0.0000000000000000001602177 * x ; 1.602177E-16 -energy ; dalton ; kilogram-square-meter-per-square-second ; 0.00000000014924180856 * x ; 1.492418E-7 energy ; joule ; kilogram-square-meter-per-square-second ; 1 * x ; 1000.0 energy ; newton-meter ; kilogram-square-meter-per-square-second ; 1 * x ; 1000.0 energy ; pound-force-foot ; kilogram-square-meter-per-square-second ; 1.3558179483314004 * x ; 1355.818 energy ; calorie ; kilogram-square-meter-per-square-second ; 4.184 * x ; 4184.0 +energy ; calorie-it ; kilogram-square-meter-per-square-second ; 4.1868 * x ; 4186.8 energy ; kilojoule ; kilogram-square-meter-per-square-second ; 1,000 * x ; 1000000.0 energy ; british-thermal-unit ; kilogram-square-meter-per-square-second ; 9,489.1523804/9 * x ; 1054350.0 +energy ; british-thermal-unit-it ; kilogram-square-meter-per-square-second ; 1,055.05585262 * x ; 1055056.0 energy ; foodcalorie ; kilogram-square-meter-per-square-second ; 4,184 * x ; 4184000.0 energy ; kilocalorie ; kilogram-square-meter-per-square-second ; 4,184 * x ; 4184000.0 energy ; kilowatt-hour ; kilogram-square-meter-second-per-cubic-second ; 3,600,000 * x ; 3.6E9 energy ; therm-us ; kilogram-square-meter-per-square-second ; 105,480,400 * x ; 1.054804E11 force ; newton ; kilogram-meter-per-square-second ; 1 * x ; 1000.0 force ; pound-force ; kilogram-meter-per-square-second ; 4.4482216152605 * x ; 4448.222 +force ; kilogram-force ; kilogram-meter-per-square-second ; 9.80665 * x ; 9806.65 force ; kilowatt-hour-per-100-kilometer ; kilogram-square-meter-second-per-meter-cubic-second ; 36 * x ; 36000.0 frequency ; hertz ; revolution-per-second ; 1 * x ; 1000.0 frequency ; kilohertz ; revolution-per-second ; 1,000 * x ; 1000000.0 @@ -85,19 +96,30 @@ graphics ; dot ; pixel ; 1 * x ; 1000.0 graphics ; pixel ; pixel ; 1 * x ; 1,000.00 graphics ; megapixel ; pixel ; 1,000,000 * x ; 1.0E9 illuminance ; lux ; candela-per-square-meter ; 1 * x ; 1000.0 +ionizing-radiation ; gray ; square-meter-per-square-second ; 1 * x ; 1000.0 +ionizing-radiation ; sievert ; square-meter-per-square-second ; 1 * x ; 1000.0 length ; picometer ; meter ; 0.000000000001 * x ; 1.0E-9 length ; nanometer ; meter ; 0.000000001 * x ; 1.0E-6 length ; micrometer ; meter ; 0.000001 * x ; 0.001 +length ; rin ; meter ; 0.004/121 * x ; 0.03305785 length ; point ; meter ; 0.003175/9 * x ; 0.3527778 length ; millimeter ; meter ; 0.001 * x ; 1.0 +length ; sun ; meter ; 0.4/121 * x ; 3.305785 length ; centimeter ; meter ; 0.01 * x ; 10.0 length ; inch ; meter ; 0.0254 * x ; 25.4 +length ; shaku-length ; meter ; 4/121 * x ; 33.05785 +length ; shaku-cloth ; meter ; 5/121 * x ; 41.32231 length ; decimeter ; meter ; 0.1 * x ; 100.0 +length ; ken ; meter ; 24/121 * x ; 198.3471 length ; foot ; meter ; 0.3048 * x ; 304.8 +length ; jo-jp ; meter ; 40/121 * x ; 330.5785 length ; yard ; meter ; 0.9144 * x ; 914.4 length ; meter ; meter ; 1 * x ; 1,000.00 length ; fathom ; meter ; 1.8288 * x ; 1828.8 +length ; rod ; meter ; 5.0292 * x ; 5029.2 +length ; chain ; meter ; 20.1168 * x ; 20116.8 length ; furlong ; meter ; 201.168 * x ; 201168.0 +length ; ri-jp ; meter ; 51,840/121 * x ; 428429.8 length ; kilometer ; meter ; 1,000 * x ; 1000000.0 length ; mile ; meter ; 1,609.344 * x ; 1609344.0 length ; nautical-mile ; meter ; 1,852 * x ; 1852000.0 @@ -107,19 +129,24 @@ length ; earth-radius ; meter ; 6,378,100 * x ; 6.3781E9 length ; solar-radius ; meter ; 695,700,000 * x ; 6.957E11 length ; astronomical-unit ; meter ; 149,597,870,700 * x ; 1.495979E14 length ; light-year ; meter ; 9,460,730,472,580,800 * x ; 9.46073E18 -length ; parsec ; meter ; 12,699,352,539,696,155,673,600,000/411,557,987 * x ; 3.085678E19 +length ; parsec ; meter ; 12,699,352,539,696,155,673,600,000/411557987 * x ; 3.085678E19 luminous-flux ; lumen ; candela-square-meter-per-square-meter ; 1 * x ; 1000.0 luminous-intensity ; candela ; candela ; 1 * x ; 1,000.00 +magnetic-flux ; weber ; kilogram-square-meter-per-square-second-ampere ; 1 * x ; 1000.0 +magnetic-induction ; tesla ; kilogram-per-square-second-ampere ; 1 * x ; 1000.0 +mass ; dalton ; kilogram ; 0.00000000000000000000000000166053878283 * x ; 1.660539E-24 mass ; microgram ; kilogram ; 0.000000001 * x ; 1.0E-6 mass ; milligram ; kilogram ; 0.000001 * x ; 0.001 mass ; grain ; kilogram ; 0.00006479891 * x ; 0.06479891 mass ; carat ; kilogram ; 0.0002 * x ; 0.2 +mass ; fun ; kilogram ; 0.000375 * x ; 0.375 mass ; gram ; kilogram ; 0.001 * x ; 1.0 mass ; ounce ; kilogram ; 0.028349523125 * x ; 28.34952 mass ; ounce-troy ; kilogram ; 0.03110348 * x ; 31.10348 mass ; pound ; kilogram ; 0.45359237 * x ; 453.5924 mass ; kilogram ; kilogram ; 1 * x ; 1,000.00 mass ; stone ; kilogram ; 6.35029318 * x ; 6350.293 +mass ; slug ; kilogram ; 5,560.277019075625/381 * x ; 14593.9 mass ; ton ; kilogram ; 907.18474 * x ; 907184.7 mass ; tonne ; kilogram ; 1,000 * x ; 1000000.0 mass ; earth-mass ; kilogram ; 5,972,200,000,000,000,000,000,000 * x ; 5.9722E27 @@ -143,54 +170,67 @@ pressure ; millibar ; kilogram-per-meter-square-second ; 100 * x ; 100000.0 pressure ; millimeter-ofhg ; kilogram-meter-per-square-meter-square-second ; 133.322387415 * x ; 133322.4 pressure ; kilopascal ; kilogram-per-meter-square-second ; 1,000 * x ; 1000000.0 pressure ; inch-ofhg ; kilogram-meter-per-square-meter-square-second ; 3,386.388640341 * x ; 3386389.0 -pressure ; pound-force-per-square-inch ; kilogram-meter-per-square-meter-square-second ; 111,205,540.3815125/16,129 * x ; 6894757.0 +pressure ; pound-force-per-square-inch ; kilogram-meter-per-square-meter-square-second ; 111,205,540.3815125/16129 * x ; 6894757.0 pressure ; bar ; kilogram-per-meter-square-second ; 100,000 * x ; 1.0E8 pressure ; atmosphere ; kilogram-per-meter-square-second ; 101,325 * x ; 1.01325E8 pressure ; megapascal ; kilogram-per-meter-square-second ; 1,000,000 * x ; 1.0E9 +pressure ; gasoline-energy-density ; kilogram-per-meter-square-second ; 722,250,000,000,000,000/22532213 * x ; 3.205411E13 pressure-per-length ; ofhg ; kilogram-per-square-meter-square-second ; 133,322.387415 * x ; 1.333224E8 +radioactivity ; becquerel ; per-second ; 1 * x ; 1000.0 resolution ; dot-per-inch ; pixel-per-meter ; 5,000/127 * x ; 39370.08 resolution ; pixel-per-inch ; pixel-per-meter ; 5,000/127 * x ; 39370.08 resolution ; dot-per-centimeter ; pixel-per-meter ; 100 * x ; 100000.0 resolution ; pixel-per-centimeter ; pixel-per-meter ; 100 * x ; 100000.0 +solid-angle ; steradian ; square-revolution ; 4,290,444,930,214,144/169379976663492169 * x ; 25.3303 +speed ; beaufort ; meter-per-second ; special:beaufort(x) ; 58.6 speed ; kilometer-per-hour ; meter-per-second ; 2.5/9 * x ; 277.7778 speed ; mile-per-hour ; meter-per-second ; 0.44704 * x ; 447.04 speed ; knot ; meter-per-second ; 4.63/9 * x ; 514.4444 speed ; meter-per-second ; meter-per-second ; 1 * x ; 1,000.00 substance-amount ; item ; item ; 1 * x ; 1,000.00 substance-amount ; mole ; item ; 602,214,076,000,000,000,000,000 * x ; 6.022141E26 -temperature ; fahrenheit ; kelvin ; 5/9 * x - 2,298.35/9 ; 810.9278 +temperature ; rankine ; kelvin ; 5/9 * x ; 555.5556 +temperature ; fahrenheit ; kelvin ; 5/9 * x + 2,298.35/9 ; 810.9278 temperature ; kelvin ; kelvin ; 1 * x ; 1,000.00 -temperature ; celsius ; kelvin ; 1 * x - 273.15 ; 1273.15 +temperature ; celsius ; kelvin ; 1 * x + 273.15 ; 1273.15 typewidth ; em ; em ; 1 * x ; 1,000.00 voltage ; volt ; kilogram-square-meter-per-cubic-second-ampere ; 1 * x ; 1000.0 volume ; drop ; cubic-meter ; 0.0000001540287998046875/3 * x ; 5.134293E-5 volume ; pinch ; cubic-meter ; 0.00000023104319970703125 * x ; 2.310432E-4 volume ; cubic-centimeter ; cubic-meter ; 0.000001 * x ; 0.001 volume ; milliliter ; cubic-meter ; 0.000001 * x ; 0.001 +volume ; sai ; cubic-meter ; 0.002401/1331 * x ; 0.001803907 volume ; dessert-spoon ; cubic-meter ; 0.00000184834559765625 * x ; 0.001848346 volume ; dessert-spoon-imperial ; cubic-meter ; 0.0000022197705078125 * x ; 0.002219771 volume ; dram ; cubic-meter ; 0.0000036966911953125 * x ; 0.003696691 volume ; teaspoon ; cubic-meter ; 0.00000492892159375 * x ; 0.004928922 +volume ; kosaji ; cubic-meter ; 0.000005 * x ; 0.005 volume ; centiliter ; cubic-meter ; 0.00001 * x ; 0.01 volume ; tablespoon ; cubic-meter ; 0.00001478676478125 * x ; 0.01478676 +volume ; osaji ; cubic-meter ; 0.000015 * x ; 0.015 volume ; cubic-inch ; cubic-meter ; 0.000016387064 * x ; 0.01638706 +volume ; shaku ; cubic-meter ; 0.02401/1331 * x ; 0.01803907 volume ; fluid-ounce-imperial ; cubic-meter ; 0.0000284130625 * x ; 0.02841306 volume ; fluid-ounce ; cubic-meter ; 0.0000295735295625 * x ; 0.02957353 volume ; jigger ; cubic-meter ; 0.00004436029434375 * x ; 0.04436029 +volume ; cup-jp ; cubic-meter ; 0.0001 * x ; 0.1 volume ; deciliter ; cubic-meter ; 0.0001 * x ; 0.1 volume ; cup ; cubic-meter ; 0.0002365882365 * x ; 0.2365882 volume ; cup-metric ; cubic-meter ; 0.00025 * x ; 0.25 volume ; pint ; cubic-meter ; 0.000473176473 * x ; 0.4731765 volume ; pint-metric ; cubic-meter ; 0.0005 * x ; 0.5 +volume ; pint-imperial ; cubic-meter ; 0.00056826125 * x ; 0.568261 volume ; quart ; cubic-meter ; 0.000946352946 * x ; 0.9463529 volume ; liter ; cubic-meter ; 0.001 * x ; 1.0 volume ; quart-imperial ; cubic-meter ; 0.0011365225 * x ; 1.13652 volume ; gallon ; cubic-meter ; 0.003785411784 * x ; 3.785412 volume ; gallon-imperial ; cubic-meter ; 0.00454609 * x ; 4.54609 +volume ; to-jp ; cubic-meter ; 24.01/1331 * x ; 18.03907 volume ; cubic-foot ; cubic-meter ; 0.028316846592 * x ; 28.31685 volume ; bushel ; cubic-meter ; 0.03523907016688 * x ; 35.23907 volume ; hectoliter ; cubic-meter ; 0.1 * x ; 100.0 volume ; barrel ; cubic-meter ; 0.158987294928 * x ; 158.9873 +volume ; koku ; cubic-meter ; 240.1/1331 * x ; 180.3907 volume ; cubic-yard ; cubic-meter ; 0.764554857984 * x ; 764.5549 volume ; cubic-meter ; cubic-meter ; 1 * x ; 1,000.00 volume ; megaliter ; cubic-meter ; 1,000 * x ; 1000000.0 diff --git a/test/support/data/preference_test_data.txt b/test/support/data/preference_test_data.txt index 8ceb40b..d48a968 100644 --- a/test/support/data/preference_test_data.txt +++ b/test/support/data/preference_test_data.txt @@ -1,8 +1,8 @@ # Test data for unit preferences -# Copyright © 1991-2023 Unicode, Inc. +# Copyright © 1991-2024 Unicode, Inc. # For terms of use, see http://www.unicode.org/copyright.html -# SPDX-License-Identifier: Unicode-DFS-2016 +# SPDX-License-Identifier: Unicode-3.0 # CLDR data files are interpreted according to the LDML specification (http://unicode.org/reports/tr35/) # # Format: @@ -22,241 +22,291 @@ # • no formatted with the skeleton # • no suppression of zero values (for secondary -and- units such as pound in stone-and-pound) # -# Generation: Set GENERATE_TESTS in TestUnits.java, and look at TestUnitPreferences results. +# Generation: Set GENERATE_TESTS in TestUnits.java to regenerate unitPreferencesTest.txt. -area; default; 001; 1100000; 1100000.0; square-meter; 11 / 10; 1.1; square-kilometer +area; default; 001; 1100000; 1100000.0; square-meter; 11/10; 1.1; square-kilometer area; default; 001; 1000000; 1000000.0; square-meter; 1; 1.0; square-kilometer area; default; 001; 900000; 900000.0; square-meter; 90; 90.0; hectare area; default; 001; 10000; 10000.0; square-meter; 1; 1.0; hectare area; default; 001; 9000; 9000.0; square-meter; 9000; 9000.0; square-meter area; default; 001; 1; 1.0; square-meter; 1; 1.0; square-meter -area; default; 001; 9 / 10; 0.9; square-meter; 9000; 9000.0; square-centimeter -area; default; 001; 1 / 10000; 1.0E-4; square-meter; 1; 1.0; square-centimeter -area; default; 001; 9 / 100000; 9.0E-5; square-meter; 9 / 10; 0.9; square-centimeter -area; default; GB; 222577103232 / 78125; 2848986.9213696; square-meter; 11 / 10; 1.1; square-mile -area; default; GB; 40468564224 / 15625; 2589988.110336; square-meter; 1; 1.0; square-mile -area; default; GB; 182108539008 / 78125; 2330989.2993024; square-meter; 576; 576.0; acre -area; default; GB; 316160658 / 78125; 4046.8564224; square-meter; 1; 1.0; acre -area; default; GB; 1422722961 / 390625; 3642.17078016; square-meter; 39204; 39204.0; square-foot -area; default; GB; 145161 / 1562500; 0.09290304; square-meter; 1; 1.0; square-foot -area; default; GB; 1306449 / 15625000; 0.083612736; square-meter; 648 / 5; 129.6; square-inch -area; default; GB; 16129 / 25000000; 6.4516E-4; square-meter; 1; 1.0; square-inch -area; default; GB; 145161 / 250000000; 5.80644E-4; square-meter; 9 / 10; 0.9; square-inch -area; floor; 001; 11 / 10; 1.1; square-meter; 11 / 10; 1.1; square-meter +area; default; 001; 9/10; 0.9; square-meter; 9000; 9000.0; square-centimeter +area; default; 001; 1/10000; 1.0E-4; square-meter; 1; 1.0; square-centimeter +area; default; 001; 9/100000; 9.0E-5; square-meter; 9/10; 0.9; square-centimeter + +area; default; GB; 222577103232/78125; 2848986.9213696; square-meter; 11/10; 1.1; square-mile +area; default; GB; 40468564224/15625; 2589988.110336; square-meter; 1; 1.0; square-mile +area; default; GB; 182108539008/78125; 2330989.2993024; square-meter; 576; 576.0; acre +area; default; GB; 316160658/78125; 4046.8564224; square-meter; 1; 1.0; acre +area; default; GB; 1422722961/390625; 3642.17078016; square-meter; 39204; 39204.0; square-foot +area; default; GB; 145161/1562500; 0.09290304; square-meter; 1; 1.0; square-foot +area; default; GB; 1306449/15625000; 0.083612736; square-meter; 648/5; 129.6; square-inch +area; default; GB; 16129/25000000; 6.4516E-4; square-meter; 1; 1.0; square-inch +area; default; GB; 145161/250000000; 5.80644E-4; square-meter; 9/10; 0.9; square-inch + +area; floor; 001; 11/10; 1.1; square-meter; 11/10; 1.1; square-meter area; floor; 001; 1; 1.0; square-meter; 1; 1.0; square-meter -area; floor; 001; 9 / 10; 0.9; square-meter; 9 / 10; 0.9; square-meter -area; floor; CA; 1596771 / 15625000; 0.102193344; square-meter; 11 / 10; 1.1; square-foot -area; floor; CA; 145161 / 1562500; 0.09290304; square-meter; 1; 1.0; square-foot -area; floor; CA; 1306449 / 15625000; 0.083612736; square-meter; 9 / 10; 0.9; square-foot -area; geograph; 001; 1100000; 1100000.0; square-meter; 11 / 10; 1.1; square-kilometer +area; floor; 001; 9/10; 0.9; square-meter; 9/10; 0.9; square-meter + +area; floor; CA; 1596771/15625000; 0.102193344; square-meter; 11/10; 1.1; square-foot +area; floor; CA; 145161/1562500; 0.09290304; square-meter; 1; 1.0; square-foot +area; floor; CA; 1306449/15625000; 0.083612736; square-meter; 9/10; 0.9; square-foot + +area; geograph; 001; 1100000; 1100000.0; square-meter; 11/10; 1.1; square-kilometer area; geograph; 001; 1000000; 1000000.0; square-meter; 1; 1.0; square-kilometer -area; geograph; 001; 900000; 900000.0; square-meter; 9 / 10; 0.9; square-kilometer -area; geograph; GB; 222577103232 / 78125; 2848986.9213696; square-meter; 11 / 10; 1.1; square-mile -area; geograph; GB; 40468564224 / 15625; 2589988.110336; square-meter; 1; 1.0; square-mile -area; geograph; GB; 182108539008 / 78125; 2330989.2993024; square-meter; 9 / 10; 0.9; square-mile -area; land; 001; 11000; 11000.0; square-meter; 11 / 10; 1.1; hectare +area; geograph; 001; 900000; 900000.0; square-meter; 9/10; 0.9; square-kilometer + +area; geograph; GB; 222577103232/78125; 2848986.9213696; square-meter; 11/10; 1.1; square-mile +area; geograph; GB; 40468564224/15625; 2589988.110336; square-meter; 1; 1.0; square-mile +area; geograph; GB; 182108539008/78125; 2330989.2993024; square-meter; 9/10; 0.9; square-mile + +area; land; 001; 11000; 11000.0; square-meter; 11/10; 1.1; hectare area; land; 001; 10000; 10000.0; square-meter; 1; 1.0; hectare -area; land; 001; 9000; 9000.0; square-meter; 9 / 10; 0.9; hectare -area; land; GB; 1738883619 / 390625; 4451.54206464; square-meter; 11 / 10; 1.1; acre -area; land; GB; 316160658 / 78125; 4046.8564224; square-meter; 1; 1.0; acre -area; land; GB; 1422722961 / 390625; 3642.17078016; square-meter; 9 / 10; 0.9; acre -concentration; blood-glucose; AG; 662435483600000000000000; 6.624354836E23; item-per-cubic-meter; 11 / 10; 1.1; millimole-per-liter +area; land; 001; 9000; 9000.0; square-meter; 9/10; 0.9; hectare + +area; land; GB; 1738883619/390625; 4451.54206464; square-meter; 11/10; 1.1; acre +area; land; GB; 316160658/78125; 4046.8564224; square-meter; 1; 1.0; acre +area; land; GB; 1422722961/390625; 3642.17078016; square-meter; 9/10; 0.9; acre + +concentration; blood-glucose; AG; 662435483600000000000000; 6.624354836E23; item-per-cubic-meter; 11/10; 1.1; millimole-per-liter concentration; blood-glucose; AG; 602214076000000000000000; 6.02214076E23; item-per-cubic-meter; 1; 1.0; millimole-per-liter -concentration; blood-glucose; AG; 541992668400000000000000; 5.419926684E23; item-per-cubic-meter; 9 / 10; 0.9; millimole-per-liter -concentration; blood-glucose; 001; 66243548360000000000000000000 / 1801557; 3.67701651182838E22; item-per-cubic-meter; 11 / 10; 1.1; milligram-ofglucose-per-deciliter -concentration; blood-glucose; 001; 60221407600000000000000000000 / 1801557; 3.342742283480345E22; item-per-cubic-meter; 1; 1.0; milligram-ofglucose-per-deciliter -concentration; blood-glucose; 001; 6022140760000000000000000000 / 200173; 3.008468055132311E22; item-per-cubic-meter; 9 / 10; 0.9; milligram-ofglucose-per-deciliter -concentration; default; 001; 11 / 10; 1.1; item-per-cubic-meter; 11 / 10; 1.1; item-per-cubic-meter +concentration; blood-glucose; AG; 541992668400000000000000; 5.419926684E23; item-per-cubic-meter; 9/10; 0.9; millimole-per-liter + +concentration; blood-glucose; 001; 66243548360000000000000000000/1801557; 3.67701651182838E22; item-per-cubic-meter; 11/10; 1.1; milligram-ofglucose-per-deciliter +concentration; blood-glucose; 001; 60221407600000000000000000000/1801557; 3.342742283480345E22; item-per-cubic-meter; 1; 1.0; milligram-ofglucose-per-deciliter +concentration; blood-glucose; 001; 6022140760000000000000000000/200173; 3.008468055132311E22; item-per-cubic-meter; 9/10; 0.9; milligram-ofglucose-per-deciliter + +concentration; default; 001; 11/10; 1.1; item-per-cubic-meter; 11/10; 1.1; item-per-cubic-meter concentration; default; 001; 1; 1.0; item-per-cubic-meter; 1; 1.0; item-per-cubic-meter -concentration; default; 001; 9 / 10; 0.9; item-per-cubic-meter; 9 / 10; 0.9; item-per-cubic-meter -consumption; default; 001; 11 / 1000000000; 1.1E-8; cubic-meter-per-meter; 11 / 10; 1.1; liter-per-100-kilometer -consumption; default; 001; 1 / 100000000; 1.0E-8; cubic-meter-per-meter; 1; 1.0; liter-per-100-kilometer -consumption; default; 001; 9 / 1000000000; 9.0E-9; cubic-meter-per-meter; 9 / 10; 0.9; liter-per-100-kilometer -consumption; vehicle-fuel; 001; 11 / 1000000000; 1.1E-8; cubic-meter-per-meter; 11 / 10; 1.1; liter-per-100-kilometer -consumption; vehicle-fuel; 001; 1 / 100000000; 1.0E-8; cubic-meter-per-meter; 1; 1.0; liter-per-100-kilometer -consumption; vehicle-fuel; 001; 9 / 1000000000; 9.0E-9; cubic-meter-per-meter; 9 / 10; 0.9; liter-per-100-kilometer -consumption; vehicle-fuel; BR; 11 / 10000000; 1.1E-6; cubic-meter-per-meter; 11 / 10; 1.1; liter-per-kilometer -consumption; vehicle-fuel; BR; 1 / 1000000; 1.0E-6; cubic-meter-per-meter; 1; 1.0; liter-per-kilometer -consumption; vehicle-fuel; BR; 9 / 10000000; 9.0E-7; cubic-meter-per-meter; 9 / 10; 0.9; liter-per-kilometer -consumption; vehicle-fuel; US; 112903 / 43200000000; 2.61349537037037E-6; cubic-meter-per-meter; 9 / 10; 0.9; mile-per-gallon -consumption; vehicle-fuel; US; 112903 / 48000000000; 2.352145833333333E-6; cubic-meter-per-meter; 1; 1.0; mile-per-gallon -consumption; vehicle-fuel; US; 112903 / 52800000000; 2.138314393939394E-6; cubic-meter-per-meter; 11 / 10; 1.1; mile-per-gallon -consumption; vehicle-fuel; CA; 454609 / 144840960000; 3.13867707035358E-6; cubic-meter-per-meter; 9 / 10; 0.9; mile-per-gallon-imperial -consumption; vehicle-fuel; CA; 454609 / 160934400000; 2.824809363318222E-6; cubic-meter-per-meter; 1; 1.0; mile-per-gallon-imperial -consumption; vehicle-fuel; CA; 454609 / 177027840000; 2.568008512107474E-6; cubic-meter-per-meter; 11 / 10; 1.1; mile-per-gallon-imperial -duration; default; 001; 95040; 95040.0; second; 11 / 10; 1.1; day +concentration; default; 001; 9/10; 0.9; item-per-cubic-meter; 9/10; 0.9; item-per-cubic-meter + +consumption; default; 001; 11/1000000000; 1.1E-8; cubic-meter-per-meter; 11/10; 1.1; liter-per-100-kilometer +consumption; default; 001; 1/100000000; 1.0E-8; cubic-meter-per-meter; 1; 1.0; liter-per-100-kilometer +consumption; default; 001; 9/1000000000; 9.0E-9; cubic-meter-per-meter; 9/10; 0.9; liter-per-100-kilometer + +consumption; vehicle-fuel; 001; 11/1000000000; 1.1E-8; cubic-meter-per-meter; 11/10; 1.1; liter-per-100-kilometer +consumption; vehicle-fuel; 001; 1/100000000; 1.0E-8; cubic-meter-per-meter; 1; 1.0; liter-per-100-kilometer +consumption; vehicle-fuel; 001; 9/1000000000; 9.0E-9; cubic-meter-per-meter; 9/10; 0.9; liter-per-100-kilometer + +consumption; vehicle-fuel; BR; 11/10000000; 1.1E-6; cubic-meter-per-meter; 11/10; 1.1; liter-per-kilometer +consumption; vehicle-fuel; BR; 1/1000000; 1.0E-6; cubic-meter-per-meter; 1; 1.0; liter-per-kilometer +consumption; vehicle-fuel; BR; 9/10000000; 9.0E-7; cubic-meter-per-meter; 9/10; 0.9; liter-per-kilometer + +consumption; vehicle-fuel; US; 112903/43200000000; 2.61349537037037E-6; cubic-meter-per-meter; 9/10; 0.9; mile-per-gallon +consumption; vehicle-fuel; US; 112903/48000000000; 2.352145833333333E-6; cubic-meter-per-meter; 1; 1.0; mile-per-gallon +consumption; vehicle-fuel; US; 112903/52800000000; 2.138314393939394E-6; cubic-meter-per-meter; 11/10; 1.1; mile-per-gallon + +consumption; vehicle-fuel; CA; 454609/144840960000; 3.13867707035358E-6; cubic-meter-per-meter; 9/10; 0.9; mile-per-gallon-imperial +consumption; vehicle-fuel; CA; 454609/160934400000; 2.824809363318222E-6; cubic-meter-per-meter; 1; 1.0; mile-per-gallon-imperial +consumption; vehicle-fuel; CA; 454609/177027840000; 2.568008512107474E-6; cubic-meter-per-meter; 11/10; 1.1; mile-per-gallon-imperial + +duration; default; 001; 95040; 95040.0; second; 11/10; 1.1; day duration; default; 001; 86400; 86400.0; second; 1; 1.0; day -duration; default; 001; 77760; 77760.0; second; 108 / 5; 21.6; hour +duration; default; 001; 77760; 77760.0; second; 108/5; 21.6; hour duration; default; 001; 3600; 3600.0; second; 1; 1.0; hour duration; default; 001; 3240; 3240.0; second; 54; 54.0; minute duration; default; 001; 60; 60.0; second; 1; 1.0; minute duration; default; 001; 54; 54.0; second; 54; 54.0; second duration; default; 001; 1; 1.0; second; 1; 1.0; second -duration; default; 001; 9 / 10; 0.9; second; 900; 900.0; millisecond -duration; default; 001; 1 / 1000; 0.001; second; 1; 1.0; millisecond -duration; default; 001; 9 / 10000; 9.0E-4; second; 900; 900.0; microsecond -duration; default; 001; 1 / 1000000; 1.0E-6; second; 1; 1.0; microsecond -duration; default; 001; 9 / 10000000; 9.0E-7; second; 900; 900.0; nanosecond -duration; default; 001; 1 / 1000000000; 1.0E-9; second; 1; 1.0; nanosecond -duration; default; 001; 9 / 10000000000; 9.0E-10; second; 9 / 10; 0.9; nanosecond +duration; default; 001; 9/10; 0.9; second; 900; 900.0; millisecond +duration; default; 001; 1/1000; 0.001; second; 1; 1.0; millisecond +duration; default; 001; 9/10000; 9.0E-4; second; 900; 900.0; microsecond +duration; default; 001; 1/1000000; 1.0E-6; second; 1; 1.0; microsecond +duration; default; 001; 9/10000000; 9.0E-7; second; 900; 900.0; nanosecond +duration; default; 001; 1/1000000000; 1.0E-9; second; 1; 1.0; nanosecond +duration; default; 001; 9/10000000000; 9.0E-10; second; 9/10; 0.9; nanosecond + duration; media; 001; 66; 66.0; second; 1; minute; 6; 6.0; second duration; media; 001; 60; 60.0; second; 1; minute; 0; 0.0; second duration; media; 001; 54; 54.0; second; 54; 54.0; second duration; media; 001; 1; 1.0; second; 1; 1.0; second -duration; media; 001; 9 / 10; 0.9; second; 9 / 10; 0.9; second -energy; default; 001; 3960000; 3960000.0; kilogram-square-meter-per-square-second; 11 / 10; 1.1; kilowatt-hour +duration; media; 001; 9/10; 0.9; second; 9/10; 0.9; second + +energy; default; 001; 3960000; 3960000.0; kilogram-square-meter-per-square-second; 11/10; 1.1; kilowatt-hour energy; default; 001; 3600000; 3600000.0; kilogram-square-meter-per-square-second; 1; 1.0; kilowatt-hour -energy; default; 001; 3240000; 3240000.0; kilogram-square-meter-per-square-second; 9 / 10; 0.9; kilowatt-hour -energy; food; US; 23012 / 5; 4602.4; kilogram-square-meter-per-square-second; 11 / 10; 1.1; foodcalorie +energy; default; 001; 3240000; 3240000.0; kilogram-square-meter-per-square-second; 9/10; 0.9; kilowatt-hour + +energy; food; US; 23012/5; 4602.4; kilogram-square-meter-per-square-second; 11/10; 1.1; foodcalorie energy; food; US; 4184; 4184.0; kilogram-square-meter-per-square-second; 1; 1.0; foodcalorie -energy; food; US; 18828 / 5; 3765.6; kilogram-square-meter-per-square-second; 9 / 10; 0.9; foodcalorie -energy; food; 001; 23012 / 5; 4602.4; kilogram-square-meter-per-square-second; 11 / 10; 1.1; kilocalorie +energy; food; US; 18828/5; 3765.6; kilogram-square-meter-per-square-second; 9/10; 0.9; foodcalorie + +energy; food; 001; 23012/5; 4602.4; kilogram-square-meter-per-square-second; 11/10; 1.1; kilocalorie energy; food; 001; 4184; 4184.0; kilogram-square-meter-per-square-second; 1; 1.0; kilocalorie -energy; food; 001; 18828 / 5; 3765.6; kilogram-square-meter-per-square-second; 9 / 10; 0.9; kilocalorie -length; default; 001; 1100; 1100.0; meter; 11 / 10; 1.1; kilometer +energy; food; 001; 18828/5; 3765.6; kilogram-square-meter-per-square-second; 9/10; 0.9; kilocalorie + +length; default; 001; 1100; 1100.0; meter; 11/10; 1.1; kilometer length; default; 001; 1000; 1000.0; meter; 1; 1.0; kilometer length; default; 001; 900; 900.0; meter; 900; 900.0; meter length; default; 001; 1; 1.0; meter; 1; 1.0; meter -length; default; 001; 9 / 10; 0.9; meter; 90; 90.0; centimeter -length; default; 001; 1 / 100; 0.01; meter; 1; 1.0; centimeter -length; default; 001; 9 / 1000; 0.009; meter; 9 / 10; 0.9; centimeter -length; default; GB; 1106424 / 625; 1770.2784; meter; 11 / 10; 1.1; mile -length; default; GB; 201168 / 125; 1609.344; meter; 1; 1.0; mile -length; default; GB; 905256 / 625; 1448.4096; meter; 4752; 4752.0; foot -length; default; GB; 381 / 1250; 0.3048; meter; 1; 1.0; foot -length; default; GB; 3429 / 12500; 0.27432; meter; 54 / 5; 10.8; inch -length; default; GB; 127 / 5000; 0.0254; meter; 1; 1.0; inch -length; default; GB; 1143 / 50000; 0.02286; meter; 9 / 10; 0.9; inch -length; focal-length; 001; 11 / 10000; 0.0011; meter; 11 / 10; 1.1; millimeter -length; focal-length; 001; 1 / 1000; 0.001; meter; 1; 1.0; millimeter -length; focal-length; 001; 9 / 10000; 9.0E-4; meter; 9 / 10; 0.9; millimeter -length; person; 001; 11 / 1000; 0.011; meter; 11 / 10; 1.1; centimeter -length; person; 001; 1 / 100; 0.01; meter; 1; 1.0; centimeter -length; person; 001; 9 / 1000; 0.009; meter; 9 / 10; 0.9; centimeter -length; person; CA; 1397 / 50000; 0.02794; meter; 11 / 10; 1.1; inch -length; person; CA; 127 / 5000; 0.0254; meter; 1; 1.0; inch -length; person; CA; 1143 / 50000; 0.02286; meter; 9 / 10; 0.9; inch -length; person-height; 001; 11 / 1000; 0.011; meter; 11 / 10; 1.1; centimeter -length; person-height; 001; 1 / 100; 0.01; meter; 1; 1.0; centimeter -length; person-height; 001; 9 / 1000; 0.009; meter; 9 / 10; 0.9; centimeter -length; person-height; CA; 11811 / 12500; 0.94488; meter; 3; foot; 6 / 5; 1.2; inch -length; person-height; CA; 1143 / 1250; 0.9144; meter; 3; foot; 0; 0.0; inch -length; person-height; CA; 11049 / 12500; 0.88392; meter; 174 / 5; 34.8; inch -length; person-height; CA; 127 / 5000; 0.0254; meter; 1; 1.0; inch -length; person-height; CA; 1143 / 50000; 0.02286; meter; 9 / 10; 0.9; inch -length; person-height; AT; 11 / 10; 1.1; meter; 1; meter; 10; 10.0; centimeter +length; default; 001; 9/10; 0.9; meter; 90; 90.0; centimeter +length; default; 001; 1/100; 0.01; meter; 1; 1.0; centimeter +length; default; 001; 9/1000; 0.009; meter; 9/10; 0.9; centimeter + +length; default; GB; 1106424/625; 1770.2784; meter; 11/10; 1.1; mile +length; default; GB; 201168/125; 1609.344; meter; 1; 1.0; mile +length; default; GB; 905256/625; 1448.4096; meter; 4752; 4752.0; foot +length; default; GB; 381/1250; 0.3048; meter; 1; 1.0; foot +length; default; GB; 3429/12500; 0.27432; meter; 54/5; 10.8; inch +length; default; GB; 127/5000; 0.0254; meter; 1; 1.0; inch +length; default; GB; 1143/50000; 0.02286; meter; 9/10; 0.9; inch + +length; focal-length; 001; 11/10000; 0.0011; meter; 11/10; 1.1; millimeter +length; focal-length; 001; 1/1000; 0.001; meter; 1; 1.0; millimeter +length; focal-length; 001; 9/10000; 9.0E-4; meter; 9/10; 0.9; millimeter + +length; person; 001; 11/1000; 0.011; meter; 11/10; 1.1; centimeter +length; person; 001; 1/100; 0.01; meter; 1; 1.0; centimeter +length; person; 001; 9/1000; 0.009; meter; 9/10; 0.9; centimeter + +length; person; CA; 1397/50000; 0.02794; meter; 11/10; 1.1; inch +length; person; CA; 127/5000; 0.0254; meter; 1; 1.0; inch +length; person; CA; 1143/50000; 0.02286; meter; 9/10; 0.9; inch + +length; person-height; 001; 11/1000; 0.011; meter; 11/10; 1.1; centimeter +length; person-height; 001; 1/100; 0.01; meter; 1; 1.0; centimeter +length; person-height; 001; 9/1000; 0.009; meter; 9/10; 0.9; centimeter + +length; person-height; CA; 11811/12500; 0.94488; meter; 3; foot; 6/5; 1.2; inch +length; person-height; CA; 1143/1250; 0.9144; meter; 3; foot; 0; 0.0; inch +length; person-height; CA; 11049/12500; 0.88392; meter; 174/5; 34.8; inch +length; person-height; CA; 127/5000; 0.0254; meter; 1; 1.0; inch +length; person-height; CA; 1143/50000; 0.02286; meter; 9/10; 0.9; inch + +length; person-height; AT; 11/10; 1.1; meter; 1; meter; 10; 10.0; centimeter length; person-height; AT; 1; 1.0; meter; 1; meter; 0; 0.0; centimeter -length; person-height; AT; 9 / 10; 0.9; meter; 0; meter; 90; 90.0; centimeter -length; rainfall; BR; 11 / 1000; 0.011; meter; 11 / 10; 1.1; centimeter -length; rainfall; BR; 1 / 100; 0.01; meter; 1; 1.0; centimeter -length; rainfall; BR; 9 / 1000; 0.009; meter; 9 / 10; 0.9; centimeter -length; rainfall; US; 1397 / 50000; 0.02794; meter; 11 / 10; 1.1; inch -length; rainfall; US; 127 / 5000; 0.0254; meter; 1; 1.0; inch -length; rainfall; US; 1143 / 50000; 0.02286; meter; 9 / 10; 0.9; inch -length; rainfall; 001; 11 / 10000; 0.0011; meter; 11 / 10; 1.1; millimeter -length; rainfall; 001; 1 / 1000; 0.001; meter; 1; 1.0; millimeter -length; rainfall; 001; 9 / 10000; 9.0E-4; meter; 9 / 10; 0.9; millimeter +length; person-height; AT; 9/10; 0.9; meter; 0; meter; 90; 90.0; centimeter + +length; rainfall; BR; 11/1000; 0.011; meter; 11/10; 1.1; centimeter +length; rainfall; BR; 1/100; 0.01; meter; 1; 1.0; centimeter +length; rainfall; BR; 9/1000; 0.009; meter; 9/10; 0.9; centimeter + +length; rainfall; US; 1397/50000; 0.02794; meter; 11/10; 1.1; inch +length; rainfall; US; 127/5000; 0.0254; meter; 1; 1.0; inch +length; rainfall; US; 1143/50000; 0.02286; meter; 9/10; 0.9; inch + +length; rainfall; 001; 11/10000; 0.0011; meter; 11/10; 1.1; millimeter +length; rainfall; 001; 1/1000; 0.001; meter; 1; 1.0; millimeter +length; rainfall; 001; 9/10000; 9.0E-4; meter; 9/10; 0.9; millimeter + length; road; 001; 1000; 1000.0; meter; 1; 1.0; kilometer -length; road; 001; 900; 900.0; meter; 9 / 10; 0.9; kilometer +length; road; 001; 900; 900.0; meter; 9/10; 0.9; kilometer length; road; 001; 800; 800.0; meter; 800; 800.0; meter length; road; 001; 300; 300.0; meter; 300; 300.0; meter -length; road; 001; 2999 / 10; 299.9; meter; 2999 / 10; 299.9; meter +length; road; 001; 2999/10; 299.9; meter; 2999/10; 299.9; meter length; road; 001; 10; 10.0; meter; 10; 10.0; meter -length; road; 001; 99 / 10; 9.9; meter; 99 / 10; 9.9; meter +length; road; 001; 99/10; 9.9; meter; 99/10; 9.9; meter length; road; 001; 1; 1.0; meter; 1; 1.0; meter -length; road; 001; 9 / 10; 0.9; meter; 9 / 10; 0.9; meter -length; road; US; 603504 / 625; 965.6064; meter; 3 / 5; 0.6; mile -length; road; US; 100584 / 125; 804.672; meter; 1 / 2; 0.5; mile -length; road; US; 402336 / 625; 643.7376; meter; 2112; 2112.0; foot -length; road; US; 762 / 25; 30.48; meter; 100; 100.0; foot -length; road; US; 380619 / 12500; 30.44952; meter; 999 / 10; 99.9; foot -length; road; US; 381 / 125; 3.048; meter; 10; 10.0; foot -length; road; US; 37719 / 12500; 3.01752; meter; 99 / 10; 9.9; foot -length; road; US; 381 / 1250; 0.3048; meter; 1; 1.0; foot -length; road; US; 3429 / 12500; 0.27432; meter; 9 / 10; 0.9; foot -length; road; GB; 603504 / 625; 965.6064; meter; 3 / 5; 0.6; mile -length; road; GB; 100584 / 125; 804.672; meter; 1 / 2; 0.5; mile -length; road; GB; 402336 / 625; 643.7376; meter; 704; 704.0; yard -length; road; GB; 2286 / 25; 91.44; meter; 100; 100.0; yard -length; road; GB; 1141857 / 12500; 91.34856; meter; 999 / 10; 99.9; yard -length; road; GB; 1143 / 125; 9.144; meter; 10; 10.0; yard -length; road; GB; 113157 / 12500; 9.05256; meter; 99 / 10; 9.9; yard -length; road; GB; 1143 / 1250; 0.9144; meter; 1; 1.0; yard -length; road; GB; 10287 / 12500; 0.82296; meter; 9 / 10; 0.9; yard -length; road; SE; 11000; 11000.0; meter; 11 / 10; 1.1; mile-scandinavian +length; road; 001; 9/10; 0.9; meter; 9/10; 0.9; meter + +length; road; US; 603504/625; 965.6064; meter; 3/5; 0.6; mile +length; road; US; 100584/125; 804.672; meter; 1/2; 0.5; mile +length; road; US; 402336/625; 643.7376; meter; 2112; 2112.0; foot +length; road; US; 762/25; 30.48; meter; 100; 100.0; foot +length; road; US; 380619/12500; 30.44952; meter; 999/10; 99.9; foot +length; road; US; 381/125; 3.048; meter; 10; 10.0; foot +length; road; US; 37719/12500; 3.01752; meter; 99/10; 9.9; foot +length; road; US; 381/1250; 0.3048; meter; 1; 1.0; foot +length; road; US; 3429/12500; 0.27432; meter; 9/10; 0.9; foot + +length; road; GB; 603504/625; 965.6064; meter; 3/5; 0.6; mile +length; road; GB; 100584/125; 804.672; meter; 1/2; 0.5; mile +length; road; GB; 402336/625; 643.7376; meter; 704; 704.0; yard +length; road; GB; 2286/25; 91.44; meter; 100; 100.0; yard +length; road; GB; 1141857/12500; 91.34856; meter; 999/10; 99.9; yard +length; road; GB; 1143/125; 9.144; meter; 10; 10.0; yard +length; road; GB; 113157/12500; 9.05256; meter; 99/10; 9.9; yard +length; road; GB; 1143/1250; 0.9144; meter; 1; 1.0; yard +length; road; GB; 10287/12500; 0.82296; meter; 9/10; 0.9; yard + +length; road; SE; 11000; 11000.0; meter; 11/10; 1.1; mile-scandinavian length; road; SE; 10000; 10000.0; meter; 1; 1.0; mile-scandinavian length; road; SE; 9000; 9000.0; meter; 9; 9.0; kilometer length; road; SE; 1000; 1000.0; meter; 1; 1.0; kilometer length; road; SE; 900; 900.0; meter; 900; 900.0; meter length; road; SE; 300; 300.0; meter; 300; 300.0; meter -length; road; SE; 2999 / 10; 299.9; meter; 2999 / 10; 299.9; meter +length; road; SE; 2999/10; 299.9; meter; 2999/10; 299.9; meter length; road; SE; 10; 10.0; meter; 10; 10.0; meter -length; road; SE; 99 / 10; 9.9; meter; 99 / 10; 9.9; meter +length; road; SE; 99/10; 9.9; meter; 99/10; 9.9; meter length; road; SE; 1; 1.0; meter; 1; 1.0; meter -length; road; SE; 9 / 10; 0.9; meter; 9 / 10; 0.9; meter -length; snowfall; 001; 11 / 1000; 0.011; meter; 11 / 10; 1.1; centimeter -length; snowfall; 001; 1 / 100; 0.01; meter; 1; 1.0; centimeter -length; snowfall; 001; 9 / 1000; 0.009; meter; 9 / 10; 0.9; centimeter -length; snowfall; US; 1397 / 50000; 0.02794; meter; 11 / 10; 1.1; inch -length; snowfall; US; 127 / 5000; 0.0254; meter; 1; 1.0; inch -length; snowfall; US; 1143 / 50000; 0.02286; meter; 9 / 10; 0.9; inch -length; vehicle; GB; 4191 / 12500; 0.33528; meter; 1; foot; 6 / 5; 1.2; inch -length; vehicle; GB; 381 / 1250; 0.3048; meter; 1; foot; 0; 0.0; inch -length; vehicle; GB; 3429 / 12500; 0.27432; meter; 0; foot; 54 / 5; 10.8; inch -length; vehicle; 001; 11 / 10; 1.1; meter; 11 / 10; 1.1; meter +length; road; SE; 9/10; 0.9; meter; 9/10; 0.9; meter + +length; snowfall; 001; 11/1000; 0.011; meter; 11/10; 1.1; centimeter +length; snowfall; 001; 1/100; 0.01; meter; 1; 1.0; centimeter +length; snowfall; 001; 9/1000; 0.009; meter; 9/10; 0.9; centimeter + +length; snowfall; US; 1397/50000; 0.02794; meter; 11/10; 1.1; inch +length; snowfall; US; 127/5000; 0.0254; meter; 1; 1.0; inch +length; snowfall; US; 1143/50000; 0.02286; meter; 9/10; 0.9; inch + +length; vehicle; GB; 4191/12500; 0.33528; meter; 1; foot; 6/5; 1.2; inch +length; vehicle; GB; 381/1250; 0.3048; meter; 1; foot; 0; 0.0; inch +length; vehicle; GB; 3429/12500; 0.27432; meter; 0; foot; 54/5; 10.8; inch + +length; vehicle; 001; 11/10; 1.1; meter; 11/10; 1.1; meter length; vehicle; 001; 1; 1.0; meter; 1; 1.0; meter -length; vehicle; 001; 9 / 10; 0.9; meter; 9 / 10; 0.9; meter -length; visiblty; 001; 200; 200.0; meter; 1 / 5; 0.2; kilometer -length; visiblty; 001; 100; 100.0; meter; 1 / 10; 0.1; kilometer +length; vehicle; 001; 9/10; 0.9; meter; 9/10; 0.9; meter + +length; visiblty; 001; 200; 200.0; meter; 1/5; 0.2; kilometer +length; visiblty; 001; 100; 100.0; meter; 1/10; 0.1; kilometer length; visiblty; 001; 1; 1.0; meter; 1; 1.0; meter -length; visiblty; 001; 9 / 10; 0.9; meter; 9 / 10; 0.9; meter +length; visiblty; 001; 9/10; 0.9; meter; 9/10; 0.9; meter length; visiblty; 001; 0; 0.0; meter; 0; 0.0; meter -length; visiblty; DE; 11 / 10; 1.1; meter; 11 / 10; 1.1; meter + +length; visiblty; DE; 11/10; 1.1; meter; 11/10; 1.1; meter length; visiblty; DE; 1; 1.0; meter; 1; 1.0; meter -length; visiblty; DE; 9 / 10; 0.9; meter; 9 / 10; 0.9; meter -length; visiblty; GB; 1106424 / 625; 1770.2784; meter; 11 / 10; 1.1; mile -length; visiblty; GB; 201168 / 125; 1609.344; meter; 1; 1.0; mile -length; visiblty; GB; 905256 / 625; 1448.4096; meter; 4752; 4752.0; foot -length; visiblty; GB; 381 / 1250; 0.3048; meter; 1; 1.0; foot -length; visiblty; GB; 3429 / 12500; 0.27432; meter; 9 / 10; 0.9; foot -mass; default; 001; 1100; 1100.0; kilogram; 11 / 10; 1.1; tonne +length; visiblty; DE; 9/10; 0.9; meter; 9/10; 0.9; meter + +length; visiblty; GB; 1106424/625; 1770.2784; meter; 11/10; 1.1; mile +length; visiblty; GB; 201168/125; 1609.344; meter; 1; 1.0; mile +length; visiblty; GB; 905256/625; 1448.4096; meter; 4752; 4752.0; foot +length; visiblty; GB; 381/1250; 0.3048; meter; 1; 1.0; foot +length; visiblty; GB; 3429/12500; 0.27432; meter; 9/10; 0.9; foot + +mass; default; 001; 1100; 1100.0; kilogram; 11/10; 1.1; tonne mass; default; 001; 1000; 1000.0; kilogram; 1; 1.0; tonne mass; default; 001; 900; 900.0; kilogram; 900; 900.0; kilogram mass; default; 001; 1; 1.0; kilogram; 1; 1.0; kilogram -mass; default; 001; 9 / 10; 0.9; kilogram; 900; 900.0; gram -mass; default; 001; 1 / 1000; 0.001; kilogram; 1; 1.0; gram -mass; default; 001; 9 / 10000; 9.0E-4; kilogram; 900; 900.0; milligram -mass; default; 001; 1 / 1000000; 1.0E-6; kilogram; 1; 1.0; milligram -mass; default; 001; 9 / 10000000; 9.0E-7; kilogram; 900; 900.0; microgram -mass; default; 001; 1 / 1000000000; 1.0E-9; kilogram; 1; 1.0; microgram -mass; default; 001; 9 / 10000000000; 9.0E-10; kilogram; 9 / 10; 0.9; microgram -mass; default; GB; 498951607 / 500000; 997.903214; kilogram; 11 / 10; 1.1; ton -mass; default; GB; 45359237 / 50000; 907.18474; kilogram; 1; 1.0; ton -mass; default; GB; 408233133 / 500000; 816.466266; kilogram; 1800; 1800.0; pound -mass; default; GB; 45359237 / 100000000; 0.45359237; kilogram; 1; 1.0; pound -mass; default; GB; 408233133 / 1000000000; 0.408233133; kilogram; 72 / 5; 14.4; ounce -mass; default; GB; 45359237 / 1600000000; 0.028349523125; kilogram; 1; 1.0; ounce -mass; default; GB; 408233133 / 16000000000; 0.0255145708125; kilogram; 9 / 10; 0.9; ounce -mass; person; 001; 11 / 10; 1.1; kilogram; 11 / 10; 1.1; kilogram +mass; default; 001; 9/10; 0.9; kilogram; 900; 900.0; gram +mass; default; 001; 1/1000; 0.001; kilogram; 1; 1.0; gram +mass; default; 001; 9/10000; 9.0E-4; kilogram; 900; 900.0; milligram +mass; default; 001; 1/1000000; 1.0E-6; kilogram; 1; 1.0; milligram +mass; default; 001; 9/10000000; 9.0E-7; kilogram; 900; 900.0; microgram +mass; default; 001; 1/1000000000; 1.0E-9; kilogram; 1; 1.0; microgram +mass; default; 001; 9/10000000000; 9.0E-10; kilogram; 9/10; 0.9; microgram + +mass; default; GB; 498951607/500000; 997.903214; kilogram; 11/10; 1.1; ton +mass; default; GB; 45359237/50000; 907.18474; kilogram; 1; 1.0; ton +mass; default; GB; 408233133/500000; 816.466266; kilogram; 1800; 1800.0; pound +mass; default; GB; 45359237/100000000; 0.45359237; kilogram; 1; 1.0; pound +mass; default; GB; 408233133/1000000000; 0.408233133; kilogram; 72/5; 14.4; ounce +mass; default; GB; 45359237/1600000000; 0.028349523125; kilogram; 1; 1.0; ounce +mass; default; GB; 408233133/16000000000; 0.0255145708125; kilogram; 9/10; 0.9; ounce + +mass; person; 001; 11/10; 1.1; kilogram; 11/10; 1.1; kilogram mass; person; 001; 1; 1.0; kilogram; 1; 1.0; kilogram -mass; person; 001; 9 / 10; 0.9; kilogram; 900; 900.0; gram -mass; person; 001; 1 / 1000; 0.001; kilogram; 1; 1.0; gram -mass; person; 001; 9 / 10000; 9.0E-4; kilogram; 9 / 10; 0.9; gram -mass; person; US; 498951607 / 1000000000; 0.498951607; kilogram; 11 / 10; 1.1; pound -mass; person; US; 45359237 / 100000000; 0.45359237; kilogram; 1; 1.0; pound -mass; person; US; 408233133 / 1000000000; 0.408233133; kilogram; 0; pound; 72 / 5; 14.4; ounce -mass; person; GB; 3492661249 / 500000000; 6.985322498; kilogram; 1; stone; 7 / 5; 1.4; pound -mass; person; GB; 317514659 / 50000000; 6.35029318; kilogram; 1; stone; 0; 0.0; pound -mass; person; GB; 2857631931 / 500000000; 5.715263862; kilogram; 12; pound; 48 / 5; 9.6; ounce -mass; person; GB; 45359237 / 100000000; 0.45359237; kilogram; 1; pound; 0; 0.0; ounce -mass; person; GB; 408233133 / 1000000000; 0.408233133; kilogram; 0; pound; 72 / 5; 14.4; ounce -mass; person; HK; 498951607 / 1000000000; 0.498951607; kilogram; 1; pound; 8 / 5; 1.6; ounce -mass; person; HK; 45359237 / 100000000; 0.45359237; kilogram; 1; pound; 0; 0.0; ounce -mass; person; HK; 408233133 / 1000000000; 0.408233133; kilogram; 0; pound; 72 / 5; 14.4; ounce -mass-density; default; 001; 11 / 10; 1.1; kilogram-per-cubic-meter; 11 / 10; 1.1; kilogram-per-cubic-meter +mass; person; 001; 9/10; 0.9; kilogram; 900; 900.0; gram +mass; person; 001; 1/1000; 0.001; kilogram; 1; 1.0; gram +mass; person; 001; 9/10000; 9.0E-4; kilogram; 9/10; 0.9; gram + +mass; person; US; 498951607/1000000000; 0.498951607; kilogram; 11/10; 1.1; pound +mass; person; US; 45359237/100000000; 0.45359237; kilogram; 1; 1.0; pound +mass; person; US; 408233133/1000000000; 0.408233133; kilogram; 0; pound; 72/5; 14.4; ounce + +mass; person; GB; 3492661249/500000000; 6.985322498; kilogram; 1; stone; 7/5; 1.4; pound +mass; person; GB; 317514659/50000000; 6.35029318; kilogram; 1; stone; 0; 0.0; pound +mass; person; GB; 2857631931/500000000; 5.715263862; kilogram; 12; pound; 48/5; 9.6; ounce +mass; person; GB; 45359237/100000000; 0.45359237; kilogram; 1; pound; 0; 0.0; ounce +mass; person; GB; 408233133/1000000000; 0.408233133; kilogram; 0; pound; 72/5; 14.4; ounce + +mass; person; HK; 498951607/1000000000; 0.498951607; kilogram; 1; pound; 8/5; 1.6; ounce +mass; person; HK; 45359237/100000000; 0.45359237; kilogram; 1; pound; 0; 0.0; ounce +mass; person; HK; 408233133/1000000000; 0.408233133; kilogram; 0; pound; 72/5; 14.4; ounce + +mass-density; default; 001; 11/10; 1.1; kilogram-per-cubic-meter; 11/10; 1.1; kilogram-per-cubic-meter mass-density; default; 001; 1; 1.0; kilogram-per-cubic-meter; 1; 1.0; kilogram-per-cubic-meter -mass-density; default; 001; 9 / 10; 0.9; kilogram-per-cubic-meter; 9 / 10; 0.9; kilogram-per-cubic-meter -power; default; 001; 1100000000; 1.1E9; kilogram-square-meter-per-cubic-second; 11 / 10; 1.1; gigawatt +mass-density; default; 001; 9/10; 0.9; kilogram-per-cubic-meter; 9/10; 0.9; kilogram-per-cubic-meter + +power; default; 001; 1100000000; 1.1E9; kilogram-square-meter-per-cubic-second; 11/10; 1.1; gigawatt power; default; 001; 1000000000; 1.0E9; kilogram-square-meter-per-cubic-second; 1; 1.0; gigawatt power; default; 001; 900000000; 9.0E8; kilogram-square-meter-per-cubic-second; 900; 900.0; megawatt power; default; 001; 1000000; 1000000.0; kilogram-square-meter-per-cubic-second; 1; 1.0; megawatt @@ -264,130 +314,163 @@ power; default; 001; 900000; 900000.0; kilogram-square-meter-per-cubic-second; 9 power; default; 001; 1000; 1000.0; kilogram-square-meter-per-cubic-second; 1; 1.0; kilowatt power; default; 001; 900; 900.0; kilogram-square-meter-per-cubic-second; 900; 900.0; watt power; default; 001; 1; 1.0; kilogram-square-meter-per-cubic-second; 1; 1.0; watt -power; default; 001; 9 / 10; 0.9; kilogram-square-meter-per-cubic-second; 900; 900.0; milliwatt -power; default; 001; 1 / 1000; 0.001; kilogram-square-meter-per-cubic-second; 1; 1.0; milliwatt -power; default; 001; 9 / 10000; 9.0E-4; kilogram-square-meter-per-cubic-second; 9 / 10; 0.9; milliwatt -power; engine; 001; 1100; 1100.0; kilogram-square-meter-per-cubic-second; 11 / 10; 1.1; kilowatt +power; default; 001; 9/10; 0.9; kilogram-square-meter-per-cubic-second; 900; 900.0; milliwatt +power; default; 001; 1/1000; 0.001; kilogram-square-meter-per-cubic-second; 1; 1.0; milliwatt +power; default; 001; 9/10000; 9.0E-4; kilogram-square-meter-per-cubic-second; 9/10; 0.9; milliwatt + +power; engine; 001; 1100; 1100.0; kilogram-square-meter-per-cubic-second; 11/10; 1.1; kilowatt power; engine; 001; 1000; 1000.0; kilogram-square-meter-per-cubic-second; 1; 1.0; kilowatt -power; engine; 001; 900; 900.0; kilogram-square-meter-per-cubic-second; 9 / 10; 0.9; kilowatt -power; engine; GB; 410134929370248621 / 500000000000000; 820.2698587404972; kilogram-square-meter-per-cubic-second; 11 / 10; 1.1; horsepower -power; engine; GB; 37284993579113511 / 50000000000000; 745.6998715822702; kilogram-square-meter-per-cubic-second; 1; 1.0; horsepower -power; engine; GB; 335564942212021599 / 500000000000000; 671.1298844240432; kilogram-square-meter-per-cubic-second; 9 / 10; 0.9; horsepower -pressure; baromtrc; 001; 110; 110.0; kilogram-per-meter-square-second; 11 / 10; 1.1; hectopascal +power; engine; 001; 900; 900.0; kilogram-square-meter-per-cubic-second; 9/10; 0.9; kilowatt + +power; engine; GB; 410134929370248621/500000000000000; 820.2698587404972; kilogram-square-meter-per-cubic-second; 11/10; 1.1; horsepower +power; engine; GB; 37284993579113511/50000000000000; 745.6998715822702; kilogram-square-meter-per-cubic-second; 1; 1.0; horsepower +power; engine; GB; 335564942212021599/500000000000000; 671.1298844240432; kilogram-square-meter-per-cubic-second; 9/10; 0.9; horsepower + +pressure; baromtrc; 001; 110; 110.0; kilogram-per-meter-square-second; 11/10; 1.1; hectopascal pressure; baromtrc; 001; 100; 100.0; kilogram-per-meter-square-second; 1; 1.0; hectopascal -pressure; baromtrc; 001; 90; 90.0; kilogram-per-meter-square-second; 9 / 10; 0.9; hectopascal -pressure; baromtrc; IN; 37250275043751 / 10000000000; 3725.0275043751; kilogram-per-meter-square-second; 11 / 10; 1.1; inch-ofhg -pressure; baromtrc; IN; 3386388640341 / 1000000000; 3386.388640341; kilogram-per-meter-square-second; 1; 1.0; inch-ofhg -pressure; baromtrc; IN; 30477497763069 / 10000000000; 3047.7497763069; kilogram-per-meter-square-second; 9 / 10; 0.9; inch-ofhg -pressure; baromtrc; BR; 110; 110.0; kilogram-per-meter-square-second; 11 / 10; 1.1; millibar +pressure; baromtrc; 001; 90; 90.0; kilogram-per-meter-square-second; 9/10; 0.9; hectopascal + +pressure; baromtrc; US; 37250275043751/10000000000; 3725.0275043751; kilogram-per-meter-square-second; 11/10; 1.1; inch-ofhg +pressure; baromtrc; US; 3386388640341/1000000000; 3386.388640341; kilogram-per-meter-square-second; 1; 1.0; inch-ofhg +pressure; baromtrc; US; 30477497763069/10000000000; 3047.7497763069; kilogram-per-meter-square-second; 9/10; 0.9; inch-ofhg + +pressure; baromtrc; BR; 110; 110.0; kilogram-per-meter-square-second; 11/10; 1.1; millibar pressure; baromtrc; BR; 100; 100.0; kilogram-per-meter-square-second; 1; 1.0; millibar -pressure; baromtrc; BR; 90; 90.0; kilogram-per-meter-square-second; 9 / 10; 0.9; millibar -pressure; baromtrc; MX; 293309252313 / 2000000000; 146.6546261565; kilogram-per-meter-square-second; 11 / 10; 1.1; millimeter-ofhg -pressure; baromtrc; MX; 26664477483 / 200000000; 133.322387415; kilogram-per-meter-square-second; 1; 1.0; millimeter-ofhg -pressure; baromtrc; MX; 239980297347 / 2000000000; 119.9901486735; kilogram-per-meter-square-second; 9 / 10; 0.9; millimeter-ofhg -pressure; default; 001; 1100000; 1100000.0; kilogram-per-meter-square-second; 11 / 10; 1.1; megapascal +pressure; baromtrc; BR; 90; 90.0; kilogram-per-meter-square-second; 9/10; 0.9; millibar + +pressure; baromtrc; MX; 293309252313/2000000000; 146.6546261565; kilogram-per-meter-square-second; 11/10; 1.1; millimeter-ofhg +pressure; baromtrc; MX; 26664477483/200000000; 133.322387415; kilogram-per-meter-square-second; 1; 1.0; millimeter-ofhg +pressure; baromtrc; MX; 239980297347/2000000000; 119.9901486735; kilogram-per-meter-square-second; 9/10; 0.9; millimeter-ofhg + +pressure; default; 001; 1100000; 1100000.0; kilogram-per-meter-square-second; 11/10; 1.1; megapascal pressure; default; 001; 1000000; 1000000.0; kilogram-per-meter-square-second; 1; 1.0; megapascal pressure; default; 001; 900000; 900000.0; kilogram-per-meter-square-second; 900000; 900000.0; pascal pressure; default; 001; 1; 1.0; kilogram-per-meter-square-second; 1; 1.0; pascal -pressure; default; 001; 9 / 10; 0.9; kilogram-per-meter-square-second; 9 / 10; 0.9; pascal -pressure; default; GB; 97860875535731 / 12903200000; 7584.233022485197; kilogram-per-meter-square-second; 11 / 10; 1.1; pound-force-per-square-inch -pressure; default; GB; 8896443230521 / 1290320000; 6894.757293168361; kilogram-per-meter-square-second; 1; 1.0; pound-force-per-square-inch -pressure; default; GB; 80067989074689 / 12903200000; 6205.281563851525; kilogram-per-meter-square-second; 9 / 10; 0.9; pound-force-per-square-inch -speed; default; 001; 11 / 36; 0.3055555555555556; meter-per-second; 11 / 10; 1.1; kilometer-per-hour -speed; default; 001; 5 / 18; 0.2777777777777778; meter-per-second; 1; 1.0; kilometer-per-hour -speed; default; 001; 1 / 4; 0.25; meter-per-second; 9 / 10; 0.9; kilometer-per-hour -speed; default; GB; 15367 / 31250; 0.491744; meter-per-second; 11 / 10; 1.1; mile-per-hour -speed; default; GB; 1397 / 3125; 0.44704; meter-per-second; 1; 1.0; mile-per-hour -speed; default; GB; 12573 / 31250; 0.402336; meter-per-second; 9 / 10; 0.9; mile-per-hour -speed; rainfall; 001; 11 / 36000000; 3.055555555555556E-7; meter-per-second; 11 / 10; 1.1; millimeter-per-hour -speed; rainfall; 001; 1 / 3600000; 2.777777777777778E-7; meter-per-second; 1; 1.0; millimeter-per-hour -speed; rainfall; 001; 1 / 4000000; 2.5E-7; meter-per-second; 9 / 10; 0.9; millimeter-per-hour -speed; rainfall; BR; 11 / 3600000; 3.055555555555556E-6; meter-per-second; 11 / 10; 1.1; centimeter-per-hour -speed; rainfall; BR; 1 / 360000; 2.777777777777778E-6; meter-per-second; 1; 1.0; centimeter-per-hour -speed; rainfall; BR; 1 / 400000; 2.5E-6; meter-per-second; 9 / 10; 0.9; centimeter-per-hour -speed; rainfall; US; 1397 / 180000000; 7.761111111111112E-6; meter-per-second; 11 / 10; 1.1; inch-per-hour -speed; rainfall; US; 127 / 18000000; 7.055555555555556E-6; meter-per-second; 1; 1.0; inch-per-hour -speed; rainfall; US; 127 / 20000000; 6.35E-6; meter-per-second; 9 / 10; 0.9; inch-per-hour -speed; snowfall; 001; 11 / 3600000; 3.055555555555556E-6; meter-per-second; 11 / 10; 1.1; centimeter-per-hour -speed; snowfall; 001; 1 / 360000; 2.777777777777778E-6; meter-per-second; 1; 1.0; centimeter-per-hour -speed; snowfall; 001; 1 / 400000; 2.5E-6; meter-per-second; 9 / 10; 0.9; centimeter-per-hour -speed; snowfall; US; 1397 / 180000000; 7.761111111111112E-6; meter-per-second; 11 / 10; 1.1; inch-per-hour -speed; snowfall; US; 127 / 18000000; 7.055555555555556E-6; meter-per-second; 1; 1.0; inch-per-hour -speed; snowfall; US; 127 / 20000000; 6.35E-6; meter-per-second; 9 / 10; 0.9; inch-per-hour -speed; wind; 001; 11 / 36; 0.3055555555555556; meter-per-second; 11 / 10; 1.1; kilometer-per-hour -speed; wind; 001; 5 / 18; 0.2777777777777778; meter-per-second; 1; 1.0; kilometer-per-hour -speed; wind; 001; 1 / 4; 0.25; meter-per-second; 9 / 10; 0.9; kilometer-per-hour -speed; wind; FI; 11 / 10; 1.1; meter-per-second; 11 / 10; 1.1; meter-per-second +pressure; default; 001; 9/10; 0.9; kilogram-per-meter-square-second; 9/10; 0.9; pascal + +pressure; default; GB; 97860875535731/12903200000; 7584.233022485197; kilogram-per-meter-square-second; 11/10; 1.1; pound-force-per-square-inch +pressure; default; GB; 8896443230521/1290320000; 6894.757293168361; kilogram-per-meter-square-second; 1; 1.0; pound-force-per-square-inch +pressure; default; GB; 80067989074689/12903200000; 6205.281563851525; kilogram-per-meter-square-second; 9/10; 0.9; pound-force-per-square-inch + +speed; default; 001; 11/36; 0.3055555555555556; meter-per-second; 11/10; 1.1; kilometer-per-hour +speed; default; 001; 5/18; 0.2777777777777778; meter-per-second; 1; 1.0; kilometer-per-hour +speed; default; 001; 1/4; 0.25; meter-per-second; 9/10; 0.9; kilometer-per-hour + +speed; default; GB; 15367/31250; 0.491744; meter-per-second; 11/10; 1.1; mile-per-hour +speed; default; GB; 1397/3125; 0.44704; meter-per-second; 1; 1.0; mile-per-hour +speed; default; GB; 12573/31250; 0.402336; meter-per-second; 9/10; 0.9; mile-per-hour + +speed; rainfall; 001; 11/36000000; 3.055555555555556E-7; meter-per-second; 11/10; 1.1; millimeter-per-hour +speed; rainfall; 001; 1/3600000; 2.777777777777778E-7; meter-per-second; 1; 1.0; millimeter-per-hour +speed; rainfall; 001; 1/4000000; 2.5E-7; meter-per-second; 9/10; 0.9; millimeter-per-hour + +speed; rainfall; BR; 11/3600000; 3.055555555555556E-6; meter-per-second; 11/10; 1.1; centimeter-per-hour +speed; rainfall; BR; 1/360000; 2.777777777777778E-6; meter-per-second; 1; 1.0; centimeter-per-hour +speed; rainfall; BR; 1/400000; 2.5E-6; meter-per-second; 9/10; 0.9; centimeter-per-hour + +speed; rainfall; US; 1397/180000000; 7.761111111111112E-6; meter-per-second; 11/10; 1.1; inch-per-hour +speed; rainfall; US; 127/18000000; 7.055555555555556E-6; meter-per-second; 1; 1.0; inch-per-hour +speed; rainfall; US; 127/20000000; 6.35E-6; meter-per-second; 9/10; 0.9; inch-per-hour + +speed; snowfall; 001; 11/3600000; 3.055555555555556E-6; meter-per-second; 11/10; 1.1; centimeter-per-hour +speed; snowfall; 001; 1/360000; 2.777777777777778E-6; meter-per-second; 1; 1.0; centimeter-per-hour +speed; snowfall; 001; 1/400000; 2.5E-6; meter-per-second; 9/10; 0.9; centimeter-per-hour + +speed; snowfall; US; 1397/180000000; 7.761111111111112E-6; meter-per-second; 11/10; 1.1; inch-per-hour +speed; snowfall; US; 127/18000000; 7.055555555555556E-6; meter-per-second; 1; 1.0; inch-per-hour +speed; snowfall; US; 127/20000000; 6.35E-6; meter-per-second; 9/10; 0.9; inch-per-hour + +speed; wind; 001; 11/36; 0.3055555555555556; meter-per-second; 11/10; 1.1; kilometer-per-hour +speed; wind; 001; 5/18; 0.2777777777777778; meter-per-second; 1; 1.0; kilometer-per-hour +speed; wind; 001; 1/4; 0.25; meter-per-second; 9/10; 0.9; kilometer-per-hour + +speed; wind; FI; 11/10; 1.1; meter-per-second; 11/10; 1.1; meter-per-second speed; wind; FI; 1; 1.0; meter-per-second; 1; 1.0; meter-per-second -speed; wind; FI; 9 / 10; 0.9; meter-per-second; 9 / 10; 0.9; meter-per-second -speed; wind; US; 15367 / 31250; 0.491744; meter-per-second; 11 / 10; 1.1; mile-per-hour -speed; wind; US; 1397 / 3125; 0.44704; meter-per-second; 1; 1.0; mile-per-hour -speed; wind; US; 12573 / 31250; 0.402336; meter-per-second; 9 / 10; 0.9; mile-per-hour -temperature; default; 001; 1097 / 4; 274.25; kelvin; 11 / 10; 1.1; celsius -temperature; default; 001; 5483 / 20; 274.15; kelvin; 1; 1.0; celsius -temperature; default; 001; 5481 / 20; 274.05; kelvin; 9 / 10; 0.9; celsius -temperature; default; US; 15359 / 60; 255.9833333333333; kelvin; 11 / 10; 1.1; fahrenheit -temperature; default; US; 46067 / 180; 255.9277777777778; kelvin; 1; 1.0; fahrenheit -temperature; default; US; 46057 / 180; 255.8722222222222; kelvin; 9 / 10; 0.9; fahrenheit -temperature; weather; 001; 1097 / 4; 274.25; kelvin; 11 / 10; 1.1; celsius -temperature; weather; 001; 5483 / 20; 274.15; kelvin; 1; 1.0; celsius -temperature; weather; 001; 5481 / 20; 274.05; kelvin; 9 / 10; 0.9; celsius -temperature; weather; BS; 15359 / 60; 255.9833333333333; kelvin; 11 / 10; 1.1; fahrenheit -temperature; weather; BS; 46067 / 180; 255.9277777777778; kelvin; 1; 1.0; fahrenheit -temperature; weather; BS; 46057 / 180; 255.8722222222222; kelvin; 9 / 10; 0.9; fahrenheit -volume; default; 001; 11 / 10; 1.1; cubic-meter; 11 / 10; 1.1; cubic-meter +speed; wind; FI; 9/10; 0.9; meter-per-second; 9/10; 0.9; meter-per-second + +speed; wind; GB; 15367/31250; 0.491744; meter-per-second; 11/10; 1.1; mile-per-hour +speed; wind; GB; 1397/3125; 0.44704; meter-per-second; 1; 1.0; mile-per-hour +speed; wind; GB; 12573/31250; 0.402336; meter-per-second; 9/10; 0.9; mile-per-hour + +temperature; default; 001; 1097/4; 274.25; kelvin; 11/10; 1.1; celsius +temperature; default; 001; 5483/20; 274.15; kelvin; 1; 1.0; celsius +temperature; default; 001; 5481/20; 274.05; kelvin; 9/10; 0.9; celsius + +temperature; default; US; 15359/60; 255.9833333333333; kelvin; 11/10; 1.1; fahrenheit +temperature; default; US; 46067/180; 255.9277777777778; kelvin; 1; 1.0; fahrenheit +temperature; default; US; 46057/180; 255.8722222222222; kelvin; 9/10; 0.9; fahrenheit + +temperature; weather; 001; 1097/4; 274.25; kelvin; 11/10; 1.1; celsius +temperature; weather; 001; 5483/20; 274.15; kelvin; 1; 1.0; celsius +temperature; weather; 001; 5481/20; 274.05; kelvin; 9/10; 0.9; celsius + +temperature; weather; BS; 15359/60; 255.9833333333333; kelvin; 11/10; 1.1; fahrenheit +temperature; weather; BS; 46067/180; 255.9277777777778; kelvin; 1; 1.0; fahrenheit +temperature; weather; BS; 46057/180; 255.8722222222222; kelvin; 9/10; 0.9; fahrenheit + +volume; default; 001; 11/10; 1.1; cubic-meter; 11/10; 1.1; cubic-meter volume; default; 001; 1; 1.0; cubic-meter; 1; 1.0; cubic-meter -volume; default; 001; 9 / 10; 0.9; cubic-meter; 900000; 900000.0; cubic-centimeter -volume; default; 001; 1 / 1000000; 1.0E-6; cubic-meter; 1; 1.0; cubic-centimeter -volume; default; 001; 9 / 10000000; 9.0E-7; cubic-meter; 9 / 10; 0.9; cubic-centimeter -volume; default; GB; 608369751 / 19531250000; 0.0311485312512; cubic-meter; 11 / 10; 1.1; cubic-foot -volume; default; GB; 55306341 / 1953125000; 0.028316846592; cubic-meter; 1; 1.0; cubic-foot -volume; default; GB; 497757069 / 19531250000; 0.0254851619328; cubic-meter; 7776 / 5; 1555.2; cubic-inch -volume; default; GB; 2048383 / 125000000000; 1.6387064E-5; cubic-meter; 1; 1.0; cubic-inch -volume; default; GB; 18435447 / 1250000000000; 1.47483576E-5; cubic-meter; 9 / 10; 0.9; cubic-inch -volume; fluid; 001; 11 / 10000; 0.0011; cubic-meter; 11 / 10; 1.1; liter -volume; fluid; 001; 1 / 1000; 0.001; cubic-meter; 1; 1.0; liter -volume; fluid; 001; 9 / 10000; 9.0E-4; cubic-meter; 900; 900.0; milliliter -volume; fluid; 001; 1 / 1000000; 1.0E-6; cubic-meter; 1; 1.0; milliliter -volume; fluid; 001; 9 / 10000000; 9.0E-7; cubic-meter; 9 / 10; 0.9; milliliter -volume; fluid; US; 5204941203 / 1250000000000; 0.0041639529624; cubic-meter; 11 / 10; 1.1; gallon -volume; fluid; US; 473176473 / 125000000000; 0.003785411784; cubic-meter; 1; 1.0; gallon -volume; fluid; US; 4258588257 / 1250000000000; 0.0034068706056; cubic-meter; 18 / 5; 3.6; quart -volume; fluid; US; 473176473 / 500000000000; 9.46352946E-4; cubic-meter; 1; 1.0; quart -volume; fluid; US; 4258588257 / 5000000000000; 8.517176514E-4; cubic-meter; 9 / 5; 1.8; pint -volume; fluid; US; 473176473 / 1000000000000; 4.73176473E-4; cubic-meter; 1; 1.0; pint -volume; fluid; US; 4258588257 / 10000000000000; 4.258588257E-4; cubic-meter; 9 / 5; 1.8; cup -volume; fluid; US; 473176473 / 2000000000000; 2.365882365E-4; cubic-meter; 1; 1.0; cup -volume; fluid; US; 4258588257 / 20000000000000; 2.1292941285E-4; cubic-meter; 36 / 5; 7.2; fluid-ounce -volume; fluid; US; 473176473 / 16000000000000; 2.95735295625E-5; cubic-meter; 1; 1.0; fluid-ounce -volume; fluid; US; 4258588257 / 160000000000000; 2.661617660625E-5; cubic-meter; 9 / 5; 1.8; tablespoon -volume; fluid; US; 473176473 / 32000000000000; 1.478676478125E-5; cubic-meter; 1; 1.0; tablespoon -volume; fluid; US; 4258588257 / 320000000000000; 1.3308088303125E-5; cubic-meter; 27 / 10; 2.7; teaspoon -volume; fluid; US; 157725491 / 32000000000000; 4.92892159375E-6; cubic-meter; 1; 1.0; teaspoon -volume; fluid; US; 1419529419 / 320000000000000; 4.436029434375E-6; cubic-meter; 9 / 10; 0.9; teaspoon -volume; fluid; GB; 5000699 / 1000000000; 0.005000699; cubic-meter; 11 / 10; 1.1; gallon-imperial -volume; fluid; GB; 454609 / 100000000; 0.00454609; cubic-meter; 1; 1.0; gallon-imperial -volume; fluid; GB; 4091481 / 1000000000; 0.004091481; cubic-meter; 144; 144.0; fluid-ounce-imperial -volume; fluid; GB; 454609 / 16000000000; 2.84130625E-5; cubic-meter; 1; 1.0; fluid-ounce-imperial -volume; fluid; GB; 4091481 / 160000000000; 2.557175625E-5; cubic-meter; 9 / 10; 0.9; fluid-ounce-imperial -volume; oil; 001; 109303765263 / 625000000000; 0.1748860244208; cubic-meter; 11 / 10; 1.1; barrel -volume; oil; 001; 9936705933 / 62500000000; 0.158987294928; cubic-meter; 1; 1.0; barrel -volume; oil; 001; 89430353397 / 625000000000; 0.1430885654352; cubic-meter; 9 / 10; 0.9; barrel -volume; vehicle; US; 5204941203 / 1250000000000; 0.0041639529624; cubic-meter; 11 / 10; 1.1; gallon -volume; vehicle; US; 473176473 / 125000000000; 0.003785411784; cubic-meter; 1; 1.0; gallon -volume; vehicle; US; 4258588257 / 1250000000000; 0.0034068706056; cubic-meter; 9 / 10; 0.9; gallon -volume; vehicle; 001; 11 / 10000; 0.0011; cubic-meter; 11 / 10; 1.1; liter -volume; vehicle; 001; 1 / 1000; 0.001; cubic-meter; 1; 1.0; liter -volume; vehicle; 001; 9 / 10000; 9.0E-4; cubic-meter; 9 / 10; 0.9; liter -year-duration; default; 001; 11 / 10; 1.1; year; 11 / 10; 1.1; year +volume; default; 001; 9/10; 0.9; cubic-meter; 900000; 900000.0; cubic-centimeter +volume; default; 001; 1/1000000; 1.0E-6; cubic-meter; 1; 1.0; cubic-centimeter +volume; default; 001; 9/10000000; 9.0E-7; cubic-meter; 9/10; 0.9; cubic-centimeter + +volume; default; GB; 608369751/19531250000; 0.0311485312512; cubic-meter; 11/10; 1.1; cubic-foot +volume; default; GB; 55306341/1953125000; 0.028316846592; cubic-meter; 1; 1.0; cubic-foot +volume; default; GB; 497757069/19531250000; 0.0254851619328; cubic-meter; 7776/5; 1555.2; cubic-inch +volume; default; GB; 2048383/125000000000; 1.6387064E-5; cubic-meter; 1; 1.0; cubic-inch +volume; default; GB; 18435447/1250000000000; 1.47483576E-5; cubic-meter; 9/10; 0.9; cubic-inch + +volume; fluid; 001; 11/10000; 0.0011; cubic-meter; 11/10; 1.1; liter +volume; fluid; 001; 1/1000; 0.001; cubic-meter; 1; 1.0; liter +volume; fluid; 001; 9/10000; 9.0E-4; cubic-meter; 900; 900.0; milliliter +volume; fluid; 001; 1/1000000; 1.0E-6; cubic-meter; 1; 1.0; milliliter +volume; fluid; 001; 9/10000000; 9.0E-7; cubic-meter; 9/10; 0.9; milliliter + +volume; fluid; US; 5204941203/1250000000000; 0.0041639529624; cubic-meter; 11/10; 1.1; gallon +volume; fluid; US; 473176473/125000000000; 0.003785411784; cubic-meter; 1; 1.0; gallon +volume; fluid; US; 4258588257/1250000000000; 0.0034068706056; cubic-meter; 18/5; 3.6; quart +volume; fluid; US; 473176473/500000000000; 9.46352946E-4; cubic-meter; 1; 1.0; quart +volume; fluid; US; 4258588257/5000000000000; 8.517176514E-4; cubic-meter; 9/5; 1.8; pint +volume; fluid; US; 473176473/1000000000000; 4.73176473E-4; cubic-meter; 1; 1.0; pint +volume; fluid; US; 4258588257/10000000000000; 4.258588257E-4; cubic-meter; 9/5; 1.8; cup +volume; fluid; US; 473176473/2000000000000; 2.365882365E-4; cubic-meter; 1; 1.0; cup +volume; fluid; US; 4258588257/20000000000000; 2.1292941285E-4; cubic-meter; 36/5; 7.2; fluid-ounce +volume; fluid; US; 473176473/16000000000000; 2.95735295625E-5; cubic-meter; 1; 1.0; fluid-ounce +volume; fluid; US; 4258588257/160000000000000; 2.661617660625E-5; cubic-meter; 9/5; 1.8; tablespoon +volume; fluid; US; 473176473/32000000000000; 1.478676478125E-5; cubic-meter; 1; 1.0; tablespoon +volume; fluid; US; 4258588257/320000000000000; 1.3308088303125E-5; cubic-meter; 27/10; 2.7; teaspoon +volume; fluid; US; 157725491/32000000000000; 4.92892159375E-6; cubic-meter; 1; 1.0; teaspoon +volume; fluid; US; 1419529419/320000000000000; 4.436029434375E-6; cubic-meter; 9/10; 0.9; teaspoon + +volume; fluid; GB; 5000699/1000000000; 0.005000699; cubic-meter; 11/10; 1.1; gallon-imperial +volume; fluid; GB; 454609/100000000; 0.00454609; cubic-meter; 1; 1.0; gallon-imperial +volume; fluid; GB; 4091481/1000000000; 0.004091481; cubic-meter; 144; 144.0; fluid-ounce-imperial +volume; fluid; GB; 454609/16000000000; 2.84130625E-5; cubic-meter; 1; 1.0; fluid-ounce-imperial +volume; fluid; GB; 4091481/160000000000; 2.557175625E-5; cubic-meter; 9/10; 0.9; fluid-ounce-imperial + +volume; oil; 001; 109303765263/625000000000; 0.1748860244208; cubic-meter; 11/10; 1.1; barrel +volume; oil; 001; 9936705933/62500000000; 0.158987294928; cubic-meter; 1; 1.0; barrel +volume; oil; 001; 89430353397/625000000000; 0.1430885654352; cubic-meter; 9/10; 0.9; barrel + +volume; vehicle; US; 5204941203/1250000000000; 0.0041639529624; cubic-meter; 11/10; 1.1; gallon +volume; vehicle; US; 473176473/125000000000; 0.003785411784; cubic-meter; 1; 1.0; gallon +volume; vehicle; US; 4258588257/1250000000000; 0.0034068706056; cubic-meter; 9/10; 0.9; gallon + +volume; vehicle; 001; 11/10000; 0.0011; cubic-meter; 11/10; 1.1; liter +volume; vehicle; 001; 1/1000; 0.001; cubic-meter; 1; 1.0; liter +volume; vehicle; 001; 9/10000; 9.0E-4; cubic-meter; 9/10; 0.9; liter + +year-duration; default; 001; 11/10; 1.1; year; 11/10; 1.1; year year-duration; default; 001; 1; 1.0; year; 1; 1.0; year -year-duration; default; 001; 9 / 10; 0.9; year; 54 / 5; 10.8; month -year-duration; default; 001; 1 / 12; 0.08333333333333333; year; 1; 1.0; month -year-duration; default; 001; 3 / 40; 0.075; year; 9 / 10; 0.9; month -year-duration; person-age; 001; 13 / 5; 2.6; year; 13 / 5; 2.6; year-person -year-duration; person-age; 001; 5 / 2; 2.5; year; 5 / 2; 2.5; year-person -year-duration; person-age; 001; 12 / 5; 2.4; year; 2; year-person; 24 / 5; 4.8; month-person +year-duration; default; 001; 9/10; 0.9; year; 54/5; 10.8; month +year-duration; default; 001; 1/12; 0.08333333333333333; year; 1; 1.0; month +year-duration; default; 001; 3/40; 0.075; year; 9/10; 0.9; month + +year-duration; person-age; 001; 13/5; 2.6; year; 13/5; 2.6; year-person +year-duration; person-age; 001; 5/2; 2.5; year; 5/2; 2.5; year-person +year-duration; person-age; 001; 12/5; 2.4; year; 2; year-person; 24/5; 4.8; month-person year-duration; person-age; 001; 1; 1.0; year; 1; year-person; 0; 0.0; month-person -year-duration; person-age; 001; 9 / 10; 0.9; year; 54 / 5; 10.8; month-person -year-duration; person-age; 001; 1 / 12; 0.08333333333333333; year; 1; 1.0; month-person -year-duration; person-age; 001; 3 / 40; 0.075; year; 9 / 10; 0.9; month-person +year-duration; person-age; 001; 9/10; 0.9; year; 54/5; 10.8; month-person +year-duration; person-age; 001; 1/12; 0.08333333333333333; year; 1; 1.0; month-person +year-duration; person-age; 001; 3/40; 0.075; year; 9/10; 0.9; month-person + diff --git a/test/unit_math_test.exs b/test/unit_math_test.exs index 0f80d1c..130f1b2 100644 --- a/test/unit_math_test.exs +++ b/test/unit_math_test.exs @@ -25,4 +25,11 @@ defmodule Cldr.Unit.Math.Test do float_unit = Cldr.Unit.new!(:meter, "12.34") |> Cldr.Unit.to_float_unit() |> Cldr.Unit.round(1) assert float_unit.value == 12.3 end + + test "Mult/2 and div/2 with a scalar" do + assert Cldr.Unit.Math.div(Cldr.Unit.new!(:meter, 10), 2) == Cldr.Unit.new!(:meter, 5) + assert Cldr.Unit.Math.mult(Cldr.Unit.new!(:meter, 10), 2) == Cldr.Unit.new!(:meter, 20) + end end + +