Int16.From
A value as a 16-bit whole number (Int16.Type), its fraction rounded away.
Group: Values, types and errors. Power Query M has it too: a query that uses it is written as in Power BI.
Syntax
Int16.From(value as any, optional culture as nullable text, optional roundingMode as nullable number) as nullable number
| Parameter | Type | Description |
|---|---|---|
value | any | The value to convert: a number, text, a logical, a date, datetime, time or duration; null gives null. |
culture | nullable text optional | The culture text is read in, such as "nb-NO"; the query's culture when left out. |
roundingMode | nullable number optional | Where a half goes: RoundingMode.ToEven (the default), RoundingMode.AwayFromZero, RoundingMode.Up, RoundingMode.Down or RoundingMode.TowardZero. Any other fraction goes to the nearest number whatever the mode. |
Returns
nullable number. The whole number; null for null.
Remarks
- Text is read in the culture, the way
Number.Fromreads it; a value that isn't a number is an error. - A fraction is rounded to the nearest whole number. A half goes to the even neighbour unless a rounding mode says otherwise: 4.5 becomes 4 and 5.5 becomes 6. The mode is used for a half only, so 12.1 is 12 even with
RoundingMode.Up. - A number outside the type's range is an error, as in Power Query: from -32,768 to 32,767.
Examples
A quantity written as text
Int16.From("12.5")
12
Halves away from zero
Int16.From(12.5, null, RoundingMode.AwayFromZero)
13