from_g function

Requirements.Units.Conversions.from_g  ยท source

Icon of from_g

Convert from gram to kilogram

Extends Modelica.Units.Icons.Conversion

Convert from gram to kilogram: kg := g/1000. The input g is the value in gram (type NonSI.Mass_g), the output kg the value in kilogram (type Modelica.Units.SI.Mass). The inverse is to_g.

The conversion is a multiplication by a constant factor, without offset, so it converts differences and rates alike; it is exact up to floating-point rounding and has no limits on the input. The function is inlined. A check model uses it to write a value of a requirement in the unit in which the requirement states it, from_g(<value as written>), so that the model reads like the statement; see Conversions. Examples.Elementary.Units.Conversions asserts its factor and the round trip to_g(from_g(7)).

Copyright © 2026 Model Based Innovation LLC. All rights reserved.

Inputs

NameTypeDescription
g inputNonSI.Mass_gValue in gram

Outputs

NameTypeDescription
kg outputSI.MassValue in kilogram