TextToFirebirdDecFloatResolver

A class used to resolve the text form of a DECFLOAT value into the FbDecFloat value that is written into a Firebird DECFLOAT column.

This IResolver<string, object> implementation converts the text form of a finite DECFLOAT value (e.g. 123.45, -0.5 or 1.5E+20) into the FbDecFloat (boxed) that the FirebirdSql.Data.FirebirdClient driver writes into a DECFLOAT(16) or DECFLOAT(34) column. The digits are kept as is, so no precision is lost, even for values that are beyond the range of a decimal. It is used by the FirebirdDecFloatToStringPropertyHandler when writing the entity property back to the database.

When the text is not a finite number (e.g. NaN or Infinity), the text itself is returned so that the conversion is done by the Firebird server. The counterpart of this class is the FirebirdDecFloatToTextResolver, which converts the value read from the column back into text.

Usability

var resolver = new TextToFirebirdDecFloatResolver();
var value = resolver.Resolve("123.45"); // FbDecFloat, 12345E-2 (boxed)
var scientific = resolver.Resolve("1.5E+20"); // FbDecFloat, 15E+19 (boxed)
var notANumber = resolver.Resolve("NaN"); // "NaN" (the text itself)