---
page_title: 'Plugin Development - Framework: Number Function Parameter'
description: >-
  Learn the number function parameter type in the provider development framework.
---

# Number Function Parameter

<Tip>

Use [Float64 Parameter](/terraform/plugin/framework/functions/parameters/float64) for 64-bit floating point numbers. Use [Int64 Parameter](/terraform/plugin/framework/functions/parameters/int64) for 64-bit integer numbers.

</Tip>

Number function parameters expect an arbitrary precision (generally over 64-bit, up to 512-bit) number value from a practitioner configuration. Values are accessible in function logic by the Go built-in `*big.Float` type or the [framework number type](/terraform/plugin/framework/handling-data/types/number).

In this Terraform configuration example, a number parameter is set to the value greater than 64 bits:

```hcl
provider::example::example(pow(2, 64) + 1)
```

## Function Definition

Use the [`function.NumberParameter` type](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework/function#NumberParameter) in the [function definition](/terraform/plugin/framework/functions/implementation#definition-method) to accept a number value.

In this example, a function definition includes a first position number parameter:

```go
func (f ExampleFunction) Definition(ctx context.Context, req function.DefinitionRequest, resp *function.DefinitionResponse) {
    resp.Definition = function.Definition{
        // ... other Definition fields ...
        Parameters: []function.Parameter{
            function.NumberParameter{
                Name: "number_param",
                // ... potentially other NumberParameter fields ...
            },
        },
    }
}
```

If the number value should be the element type of a [collection parameter type](/terraform/plugin/framework/functions/parameters#collection-parameter-types), set the `ElementType` field according to the [framework number type](/terraform/plugin/framework/handling-data/types/number). Refer to the collection parameter type documentation for additional details.

If the number value should be a value type of an [object parameter type](/terraform/plugin/framework/functions/parameters#object-parameter-type), set the `AttributeTypes` map value according to the [framework number type](/terraform/plugin/framework/handling-data/types/number). Refer to the object parameter type documentation for additional details.

### Allow Null Values

By default, Terraform will not pass null values to the function logic. Use the `AllowNullValue` field to explicitly allow null values, if there is a meaningful distinction that should occur in function logic. Enabling `AllowNullValue` requires using a Go pointer type or [framework number type](/terraform/plugin/framework/handling-data/types/number) when reading argument data.

### Allow Unknown Values

By default, Terraform will not pass unknown values to the function logic. Use the `AllowUnknownValues` field to explicitly allow unknown values, if there is a meaningful distinction that should occur in function logic. Enabling `AllowUnknownValues` requires using a [framework number type](/terraform/plugin/framework/handling-data/types/number) when reading argument data.

### Custom Types

You may want to build your own data value and type implementations to allow your provider to combine validation and other behaviors into a reusable bundle. This helps avoid duplication and ensures consistency. These implementations use the `CustomType` field in the parameter type.

Refer to [Custom Types](/terraform/plugin/framework/handling-data/types/custom) for further details on creating provider-defined types and values.

### Documentation

Refer to [function documentation](/terraform/plugin/framework/functions/documentation) for information about the `Name`, `Description`, and `MarkdownDescription` fields available.

## Reading Argument Data

The [function implementation](/terraform/plugin/framework/functions/implementation) documentation covers the general methods for reading function argument data in function logic.

When retrieving the argument value for this parameter:

* If `CustomType` is set, use its associated value type.
* If `AllowUnknownValues` is enabled, you must use the [framework number type](/terraform/plugin/framework/handling-data/types/number).
* Otherwise, use the Go built-in `*big.Float` type or [framework number type](/terraform/plugin/framework/handling-data/types/number).

In this example, a function defines a single number parameter and accesses its argument value:

```go
func (f ExampleFunction) Definition(ctx context.Context, req function.DefinitionRequest, resp *function.DefinitionResponse) {
    resp.Definition = function.Definition{
        // ... other Definition fields ...
        Parameters: []function.Parameter{
            function.NumberParameter{
                Name: "number_param",
                // ... potentially other NumberParameter fields ...
            },
        },
    }
}

func (f ExampleFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) {
    var numberArg *big.Float
    // var numberArg types.Number // e.g. with AllowUnknownValues or AllowNullValue

    resp.Error = function.ConcatFuncErrors(resp.Error, req.Arguments.Get(ctx, &numberArg))

    // numberArg is now populated
    // ... other logic ...
}
```
