PALATINELABSDocsENES

Pages

↑↓ to moveEnter to openEsc to close

Number package guide

Use Number actions to calculate, extract parts, round, format, and compare numeric values.

Version 2.17.1. Installed versions can differ. Examples are illustrative and not tested.

Jump to actions

Prerequisites

Shared fields

Number: number text with a . decimal point and no thousands separator, e.g. 3.5, or a Number variable such as $amount$. Convert a String variable to Number first.

Numeric List: a List variable, e.g. $numbers$, of numbers or number text, or a JSON array such as [1,2,3]. One bad item fails the step. A String that holds JSON is not a List.

Counts: decimalPlaces, precision and numFormatDigits are whole numbers. Decimals are dropped first (2.9 gives 2).

Actions

Assign (numberAssignToNumber)

Copy a Number to the destination.

Inputs

IdentifierEditor fieldType; required; defaultUse
inputSelect the source number variable/ valueNumberdefault 0requiredNumber.

Outputs

IdentifierTypeMeaning
resultNumberInput value.

Example

Set input=42; bind result to $answer$.

Expected result

$answer$ is Number 42.

Back to actions

Calculate Subset Sum (numberCalculateSumSubset)

Find the first group of numbers in a list that adds up to a target. Use short lists.

Inputs

IdentifierEditor fieldType; required; defaultUse
inputListList of numbersListdefault []requiredNumeric List.
sumTarget sumNumberdefault 0optionalTarget total.
thresholdSum deviation thresholdNumberdefault 0optionalHow far the total can be from sum⁠, e.g. 0.5⁠. A negative value gives no match.

Outputs

IdentifierTypeMeaning
resultListThe numbers found, in list order. Empty can mean no match, a search that stopped early, or that 0 items already match.

Example

List $numbers$, Numbers 1, 2, 3, 4. Set inputList=$numbers$, sum=7, threshold=0; bind result to $subset$.

Expected result

$subset$ is [1,2,4], the first match found, not [3,4]. The list [2,4] gives []. For long lists the search can stop early, so [] does not prove there is no match. If sum is within threshold of 0, the result is [] at once.

Back to actions

Decrement (numberDecrement)

Subtract by from source.

Inputs

IdentifierEditor fieldType; required; defaultUse
sourceEnter numberNumberdefault 0optionalNumber.
byEnter decrement valueNumberdefault 1optionalAmount to subtract. A negative value adds.

Outputs

IdentifierTypeMeaning
resultNumbersource - by⁠.

Example

Set source=10, by=3; bind result to $total$.

Expected result

$total$ is Number 7. Omitting by uses 1.

Back to actions

Get decimal part (numberGetDecimalPart)

Get the part after the decimal point, with its sign.

Inputs

IdentifierEditor fieldType; required; defaultUse
inputNumberEnter number to extract fractional part fromNumberdefault 0optionalNumber.

Outputs

IdentifierTypeMeaning
fractionAsNumberNumberThe decimal part, rounded to 12 places.
fractionsAsStringStringThe same value as number text, e.g. 0.14 or -0.14⁠.

Example

Set inputNumber=3.14. Bind fractionAsNumber to $fraction$ and fractionsAsString to $text$.

Expected result

$fraction$ is Number 0.14; $text$ is String 0.14. Input -3.14 gives -0.14; an integer gives 0. Very small fractions can round to zero.

Back to actions

Get integral part (numberGetIntegerPart)

Drop the decimals (-3.7 gives -3).

Inputs

IdentifierEditor fieldType; required; defaultUse
inputNumberEnter number to extract integral part fromNumberdefault 0optionalNumber.

Outputs

IdentifierTypeMeaning
integralAsNumberNumberThe whole-number part. Negatives move toward zero.
integralAsStringStringThe same value as number text.

Example

Set inputNumber=-3.7. Bind integralAsNumber to $integer$ and integralAsString to $text$.

Expected result

$integer$ is Number -3; $text$ is String -3. Input 3.7 gives 3; zero gives 0.

Back to actions

Get Maximum Number (numberGetMax)

Largest number in a list.

Inputs

IdentifierEditor fieldType; required; defaultUse
numbersList of numbersListdefault []requiredNumeric List.

Outputs

IdentifierTypeMeaning
resultNumberLargest value.

Example

List $numbers$, Numbers 1, 5, 3. Set numbers=$numbers$; bind result to $extreme$.

Expected result

$extreme$ is Number 5. It fails if the list is empty or an item is not a number.

Back to actions

Get Minimum Number (numberGetMin)

Smallest number in a list.

Inputs

IdentifierEditor fieldType; required; defaultUse
numbersList of numbersListdefault []requiredNumeric List.

Outputs

IdentifierTypeMeaning
resultNumberSmallest value.

Example

List $numbers$, Numbers 1, 5, 3. Set numbers=$numbers$; bind result to $extreme$.

Expected result

$extreme$ is Number 1. It fails if the list is empty or an item is not a number.

Back to actions

Increment (numberIncrement)

Add by to source.

Inputs

IdentifierEditor fieldType; required; defaultUse
sourceEnter numberNumberdefault 0optionalNumber.
byEnter increment valueNumberdefault 1optionalAmount to add. A negative value subtracts.

Outputs

IdentifierTypeMeaning
resultNumbersource + by⁠.

Example

Set source=10, by=3; bind result to $total$.

Expected result

$total$ is Number 13. Omitting by uses 1.

Back to actions

Random (numberRandomNumber)

Make a random whole number or decimal for test data. Do not use it for secrets.

Inputs

IdentifierEditor fieldType; required; defaultUse
fromValBeginning of range:Numberdefault 0optionalSmallest value. For whole numbers, a decimal limit rounds up (1.2 gives 2).
toValEnd of range:Numberdefault 0optionalMust be larger than fromVal⁠. Whole numbers: up to toVal minus 1 (after rounding up). Decimals: below toVal⁠, but rounding can reach a limit.
isRequiredPrecisionSpecify number of decimalsBooleandefault falseoptionalfalse gives a whole number. true gives a decimal with precision places.
precisionNumber of decimalNumberdefault 0optionalDecimal places, 0 to 15⁠. Other values change to the nearest limit. A 5 rounds away from zero.

Outputs

IdentifierTypeMeaning
resultNumberRandom value. You cannot set a seed.

Example

Set fromVal=1, toVal=10, isRequiredPrecision=false. Bind result to $sample$. For a decimal sample, use fromVal=0, toVal=1, isRequiredPrecision=true, precision=2.

Expected result

A whole number from 1 to 9. The decimal sample has at most two places, and rounding can give 1. It fails if toVal is not larger than fromVal. With decimal limits, a whole number can fall outside them, so use whole-number limits.

Back to actions

Round number (numberRound)

Round to a number of decimal places: nearest, up or down.

Inputs

IdentifierEditor fieldType; required; defaultUse
inputNumberNumber to RoundNumberdefault 0optionalNumber.
decimalPlacesDecimal PlacesNumberdefault 0optional0 to 15⁠. Above 15 uses 15⁠. A negative value fails.
roundingTypeRounding TypeRoundingTypedefault normaloptionalnormal⁠: nearest, and a 5 rounds away from zero. up always rounds up, down always rounds down (for negatives too).

Outputs

IdentifierTypeMeaning
resultNumberRounded Number. End zeros are not kept; use To string to show them.

Example

Set inputNumber=1.2341, decimalPlaces=2, roundingType=up; bind result to $rounded$.

Expected result

$rounded$ is 1.24. With input -1.2341, up gives -1.23 and down gives -1.24. normal turns -1.25 into -1.3 with one decimal place.

Back to actions

To string (numberToString)

Write a number as text with a set number of decimals.

Inputs

IdentifierEditor fieldType; required; defaultUse
inputEnter a numberNumberdefault 0optionalNumber.
numFormatDigitsEnter number of digits after decimal (number format)Numberdefault 0optionalDecimal places, 0 to 340⁠. Other values change to the nearest limit. The text uses a . point, keeps end zeros and has no thousands separator.

Outputs

IdentifierTypeMeaning
resultStringThe text. Save it in a String variable to keep the end zeros.

Example

Set input=35.265, numFormatDigits=3; bind result to $text$.

Expected result

$text$ is String 35.265. Input 35 with numFormatDigits=2 gives 35.00. Because numbers are not exact decimals, rounding at the last digit can surprise.

Back to actions

Conditions

Number condition (numberCondition)

Compare two numbers exactly, with no tolerance.

Inputs

IdentifierEditor fieldType; required; defaultUse
variableSource valueNumberdefault 0optionalNumber.
operatorOperatorOperatordefault EQoptionalChoose EQ (=), NEQ (≠), GT (>), GTE (≥), LT (<), or LTE (≤).
valueTarget valueNumberdefault 0optionalNumber.

Outputs

None. Use the condition in an If or other control step: true for a match, otherwise false.

Example

Set variable=5, operator=GT, value=3 on an If condition.

Expected result

The result is true. With operator=LTE it is false. Text that is not a number fails before the comparison.

Back to conditions