draft patch for strtof() - Mailing list pgsql-hackers

From Andrew Gierth
Subject draft patch for strtof()
Date
Msg-id 87d0owlqpv.fsf@news-spur.riddles.org.uk
Whole thread Raw
Responses Re: draft patch for strtof()  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: draft patch for strtof()  (Andrew Gierth <andrew@tao11.riddles.org.uk>)
List pgsql-hackers
As discussed in the Ryu thread, herewith a draft of a patch to use
strtof() for float4 input (rather than using strtod() with its
double-rounding issue).

An exhaustive search shows that this does not change the resulting
bit-pattern for any input string that could have been generated by PG
with extra_float_digits=3 set. The risk is that values generated by
other software, especially code that uses shortest-exact float output
(as a number of languages seem to do, and which PG will do if the Ryu
patch goes in) will be incorrectly input; though it appears that only
one value (7.038531e-26) is both a possible shortest-exact
representation and a rounding error (though a number of other values
round incorrectly, they are not shortest representations).

This includes a fallback to use strtod() the old way if the platform
lacks strtof(). A variant file for the new regression tests is needed
for such platforms; I've taken a stab at setting this up for the one
platform we know will need it (if there are others, the buildfarm will
let us know in due course).

-- 
Andrew (irc:RhodiumToad)


Attachment

pgsql-hackers by date:

Previous
From: M.Atıf CEYLAN
Date:
Subject: PostgreSQL-XL shared disk development question
Next
From: James Coleman
Date:
Subject: Re: Proving IS NOT NULL inference for ScalarArrayOpExpr's