---
page_title: 'Plugin Development - Framework: Float64 Type'
description: >-
  Learn the float64 value type in the provider development framework.
---

# Float64 Type

<Tip>

Use [Int64 Type](/terraform/plugin/framework/handling-data/types/int64) for 64-bit integer numbers. Use [Number Attribute](/terraform/plugin/framework/handling-data/types/number) for arbitrary precision numbers.

</Tip>

Float64 types store a 64-bit floating point number.

By default, float64 from [schema](/terraform/plugin/framework/handling-data/schemas) (configuration, plan, and state) data are represented in the framework by [`types.Float64Type`](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework/types#Float64Type) and its associated value storage type of [`types.Float64`](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework/types#Float64). These types fully support Terraform's [type system concepts](/terraform/plugin/framework/handling-data/terraform-concepts) that cannot be represented in Go built-in types, such as `*float64`. Framework types can be [extended](#extending) by provider code or shared libraries to provide specific use case functionality.

## Schema Definitions

Use one of the following attribute types to directly add a float64 value to a [schema](/terraform/plugin/framework/handling-data/schemas) or [nested attribute type](/terraform/plugin/framework/handling-data/attributes#nested-attribute-types):

| Schema Type | Attribute Type |
|-------------|----------------|
| [Data Source](/terraform/plugin/framework/data-sources) | [`schema.Float64Attribute`](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework/datasource/schema#Float64Attribute) |
| [Provider](/terraform/plugin/framework/provider) | [`schema.Float64Attribute`](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework/provider/schema#Float64Attribute) |
| [Resource](/terraform/plugin/framework/resources) | [`schema.Float64Attribute`](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework/resource/schema#Float64Attribute) |

If the float64 value should be the element type of a [collection attribute type](/terraform/plugin/framework/handling-data/attributes#collection-attribute-types), set the `ElemType` field to `types.Float64Type` or the appropriate [custom type](#extending).

If the float64 value should be a value type of an [object attribute type](/terraform/plugin/framework/handling-data/attributes#object-attribute-type), set the `AttrTypes` map value to `types.Float64Type` or the appropriate [custom type](#extending).

## Accessing Values

<Tip>

Review the [attribute documentation](/terraform/plugin/framework/handling-data/attributes/float64#accessing-values) to understand how schema-based data gets mapped into accessible values, such as a `types.Float64` in this case.

</Tip>

Access `types.Float64` information via the following methods:

* [`(types.Float64).IsNull() bool`](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework/types/basetypes#Float64Value.IsNull): Returns true if the float64 is null.
* [`(types.Float64).IsUnknown() bool`](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework/types/basetypes#Float64Value.IsUnknown): Returns true if the float64 is unknown.
* [`(types.Float64).ValueFloat64() float64`](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework/types/basetypes#Float64Value.ValueFloat64): Returns the known float64, or `0.0` if null or unknown.
* [`(types.Float64).ValueFloat64Pointer() *float64`](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework/types/basetypes#Float64Value.ValueFloat64Pointer): Returns a float64 pointer to a known value, `nil` if null, or a pointer to `0.0` if unknown.

In this example, a float64 value is checked for being null or unknown value first, before accessing its known value:

```go
// Example data model definition
// type ExampleModel struct {
//   ExampleAttribute types.Float64 `tfsdk:"example_attribute"`
// }
//
// This would be filled in, such as calling: req.Plan.Get(ctx, &data)
var data ExampleModel

// optional logic for handling null value
if data.ExampleAttribute.IsNull() {
    // ...
}

// optional logic for handling unknown value
if data.ExampleAttribute.IsUnknown() {
    // ...
}

// myFloat64 now contains a Go float64 with the known value
myFloat64 := data.ExampleAttribute.ValueFloat64()
```

## Setting Values

Call one of the following to create a `types.Float64` value:

* [`types.Float64Null()`](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework/types#Float64Null): A null float64 value.
* [`types.Float64Unknown()`](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework/types#Float64Unknown): An unknown float64 value.
* [`types.Float64Value(float64)`](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework/types#Float64Value): A known value.
* [`types.Float64PointerValue(*float64)`](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework/types#Float64PointerValue): A known value.

In this example, a known float64 value is created:

```go
types.Float64Value(1.23)
```

Otherwise, for certain framework functionality that does not require `types` implementations directly, such as:

* [`(tfsdk.State).SetAttribute()`](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework/tfsdk#State.SetAttribute)
* [`types.ListValueFrom()`](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework/types#ListValueFrom)
* [`types.MapValueFrom()`](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework/types#MapValueFrom)
* [`types.ObjectValueFrom()`](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework/types#ObjectValueFrom)
* [`types.SetValueFrom()`](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework/types#SetValueFrom)

Numbers can be automatically converted from the following Go types, pointers to these types, or any aliases of these types, such `type MyNumber int`:

* `int`, `int8`, `int16`, `int32`, `int64`
* `uint`, `uint8`, `uint16`, `uint32`, `uint64`
* `float32`, `float64`
* [`*big.Int`](https://pkg.go.dev/math/big#Int), [`*big.Float`](https://pkg.go.dev/math/big#Float)

An error will be returned if the value of the number cannot be stored in the numeric type supplied because of an overflow or other loss of precision.

In this example, a `float64` is directly used to set a float64 attribute value:

```go
diags := resp.State.SetAttribute(ctx, path.Root("example_attribute"), 1.23)
```

In this example, a `types.List` of `types.Float64` is created from a `[]float64`:

```go
listValue, diags := types.ListValueFrom(ctx, types.Float64Type, []float64{1.2, 2.4})
```

## Extending

The framework supports extending its base type implementations with [custom types](/terraform/plugin/framework/handling-data/types/custom). These can adjust expected provider code usage depending on their implementation.
