Skip to content

Commit 73685e5

Browse files
committed
Document Decimal64/Decimal128 support
1 parent fdd5b06 commit 73685e5

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

‎docs/decfloat.md‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,21 @@ Reading a `DECFLOAT` column:
2121

2222
`FbDecFloat` has explicit conversions from and to `decimal`, `double` and `float`, with the same rules.
2323

24+
### .NET 11 `Decimal64` and `Decimal128`
25+
26+
On .NET 11 or later, the IEEE 754 decimal types `System.Numerics.Decimal64` and `System.Numerics.Decimal128` match `DECFLOAT(16)` and `DECFLOAT(34)`. Conversions are exact, including the exponent (`1.10` stays `1.10`), negative zero, infinities and NaNs.
27+
28+
* Parameters: a `Decimal128` value is a `FbDbType.Dec34` parameter, a `Decimal64` or `Decimal32` value a `FbDbType.Dec16` parameter. They can also be passed to other numeric parameters. A `Decimal128` value passed to a `DECFLOAT(16)` parameter works when it fits exactly, otherwise it throws `OverflowException`.
29+
* Reader: `GetFieldValue<Decimal128>()` and `GetFieldValue<Decimal64>()` read `DECFLOAT` and the other numeric types; they throw `OverflowException` when the value does not fit exactly (e.g. a 34 digit `DECFLOAT(34)` value read as `Decimal64`).
30+
* `FbDecFloat` has explicit conversions from `Decimal32`, `Decimal64` and `Decimal128`, and to `Decimal64` and `Decimal128`.
31+
32+
```csharp
33+
command.CommandText = "insert into t (d34) values (@d34)";
34+
command.Parameters.AddWithValue("d34", Decimal128.Parse("1234567890123456789012345678.901234", CultureInfo.InvariantCulture));
35+
...
36+
var value = reader.GetFieldValue<Decimal128>(0);
37+
```
38+
2439
### Examples
2540

26-
Examples can be found in [`FbDecFloat16SupportTests`](../src/FirebirdSql.Data.FirebirdClient.Tests/FbDecFloat16SupportTests.cs) and [`FbDecFloat34SupportTests`](../src/FirebirdSql.Data.FirebirdClient.Tests/FbDecFloat34SupportTests.cs).
41+
Examples can be found in [`FbDecFloat16SupportTests`](../src/FirebirdSql.Data.FirebirdClient.Tests/FbDecFloat16SupportTests.cs), [`FbDecFloat34SupportTests`](../src/FirebirdSql.Data.FirebirdClient.Tests/FbDecFloat34SupportTests.cs) and [`FbDecimalIeee754SupportTests`](../src/FirebirdSql.Data.FirebirdClient.Tests/FbDecimalIeee754SupportTests.cs).

0 commit comments

Comments
 (0)