@@ -23,6 +23,14 @@ the Haskell 'Double' type is compatible with the PostgreSQL's 32-bit
2323since a 'Double' might lose precision if representing PostgreSQL's 64-bit
2424@bigint@, the two are /not/ considered compatible.
2525
26+Note that the 'Float' and 'Double' instances use attoparsec's 'double'
27+conversion routine, which sacrifices some accuracy for speed. If you
28+need accuracy, consider first converting data to a 'Scientific' or 'Rational'
29+type, and then converting to a floating-point type. If you are defining
30+your own 'ToRow' instances, this can be acheived simply by
31+@'fromRational' '<$>' 'field'@, although this idiom additionally compatible
32+with PostgreSQL's @numeric@ type.
33+
2634Because 'FromField' is a typeclass, one may provide conversions to
2735additional Haskell types without modifying postgresql-simple. This is
2836particularly useful for supporting PostgreSQL types that postgresql-simple
@@ -301,12 +309,14 @@ instance FromField Int64 where
301309instance FromField Integer where
302310 fromField = atto ok64 $ signed decimal
303311
304−-- | int2, float4
312+-- | int2, float4 (Uses attoparsec's 'double' routine, for
313+-- better accuracy convert to 'Scientific' or 'Rational' first)
305314instance FromField Float where
306315 fromField = atto ok (realToFrac <$> double)
307316 where ok = $(mkCompats [TI.float4,TI.int2])
308317
309−-- | int2, int4, float4, float8
318+-- | int2, int4, float4, float8 (Uses attoparsec's 'double' routine, for
319+-- better accuracy convert to 'Scientific' or 'Rational' first)
310320instance FromField Double where
311321 fromField = atto ok double
312322 where ok = $(mkCompats [TI.float4,TI.float8,TI.int2,TI.int4])