Int8.From
NumberConverts a value to an 8-bit signed integer (-128 to 127).
Syntax
Int8.From(value as any, optional culture as nullable text, optional roundingMode as nullable number) as nullable numberParameters
| Name | Type | Required | Description |
|---|---|---|---|
value | any | Yes | The value to convert. Accepts number, text, logical, or null. |
culture | text | No | An optional culture string for locale-aware parsing of text values. |
roundingMode | number | No | An optional rounding mode constant used when truncating fractional values. |
Return Value
number — An 8-bit signed integer in the range -128 to 127.
Remarks
Int8.From converts a value to a signed 8-bit integer, covering the range -128 to 127. This is the signed counterpart to Byte.From (unsigned, 0–255). Values outside the -128 to 127 range raise an error at runtime. Fractional numbers are rounded before conversion; the default rounding mode is round-half-to-even (banker's rounding). Pass RoundingMode.AwayFromZero to get conventional rounding.
This type is rarely used in typical Power Query data transformation because most integer work uses Int32.From or Int64.From. Int8.From is primarily useful when working with compact binary protocols, interfacing with systems that explicitly declare TINYINT SIGNED columns, or building custom connector schemas that must match a source's 8-bit signed integer type.
Text values are parsed as numbers — scientific notation and decimal strings are accepted. Logical true converts to 1, false to 0, and null returns null. If you need to check whether a value is within the valid range before converting, test value >= -128 and value <= 127 first.
Examples
Example 1: Convert a positive integer
Int8.From(100)Result | |
|---|---|
| 1 | 100 |
Example 2: Convert a negative integer at the lower bound
Int8.From(-128)Result | |
|---|---|
| 1 | -128 |
Example 3: Rounding a decimal — default banker's rounding vs. away-from-zero
#table(
{"Input", "Default (Banker's)", "AwayFromZero"},
{
{2.5, Int8.From(2.5), Int8.From(2.5, null, RoundingMode.AwayFromZero)},
{3.5, Int8.From(3.5), Int8.From(3.5, null, RoundingMode.AwayFromZero)}
}
)Input | Default (Banker's) | AwayFromZero | |
|---|---|---|---|
| 1 | 2.50 | 2 | 3 |
| 2 | 3.50 | 4 | 4 |