View raw Markdown
type: fhirpath-functionfunction: powercategory: Mathsection: 5.8.7source: fhirpath/functions.json

FHIRPath Function: power

{:.stu}

Raises a number to the exponent power. {:.stu}

Accepts input types of Decimal, Integer or Long. {:.stu}

The result is always a Decimal, because raising an Integer to a negative power (such as -1) produces a Decimal result. {:.stu}

If the power cannot be represented (such as -1 raised to the 0.5), the result is empty. {:.stu}

If the input is empty, or exponent is empty, the result is empty. {:.stu}

If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment. {:.stu}

2.power(3) // 8
2.5.power(2) // 6.25
2.power(-1) // 0.5
(-1).power(0.5) // empty ({ })

{:.stu}

Summary

Description

Raises a number to the exponent power. This function can operate on Decimal and Integer types, but not on Quantity. If this function is used with Integers, the result is an Integer. If the function is used with Decimals, the result is a Decimal. If the function is used with a mixture of Integer and Decimal, the Integer is implicitly converted to a Decimal and the result is a Decimal. Note that if both the base and the exponent are integers and the exponent is negative, the result is empty since that might result in a Decimal value, not an Integer (the expected output type for this case). If the power cannot be represented (such as the -1 raised to the 0.5), the result is empty.

Arguments

Type Mapping

Example

2.power(3) // 8
2.5.power(2) // 6.25
(-1).power(0.5) // empty ({ })