-- test for over and under flow INSERTINTO FLOAT4_TBL(f1) VALUES ('10e70'); INSERTINTO FLOAT4_TBL(f1) VALUES ('-10e70'); INSERTINTO FLOAT4_TBL(f1) VALUES ('10e-70'); INSERTINTO FLOAT4_TBL(f1) VALUES ('-10e-70');
-- Also try it with non-error-throwing API SELECT pg_input_is_valid('34.5', 'float4'); SELECT pg_input_is_valid('xyz', 'float4'); SELECT pg_input_is_valid('1e400', 'float4'); SELECT * FROM pg_input_error_info('1e400', 'float4');
-- special inputs SELECT'NaN'::float4; SELECT'nan'::float4; SELECT' NAN '::float4; SELECT'infinity'::float4; SELECT' -INFINiTY '::float4; -- bad special inputs SELECT'N A N'::float4; SELECT'NaN x'::float4; SELECT' INFINITY x'::float4;
-- Test that the smallest possible normalized input value inputs -- correctly, either in 9-significant-digit or shortest-decimal -- format. -- -- exact val is 1.1754943508... -- shortest val is 1.1754944000 -- midpoint to next val is 1.1754944208...
-- test output (and round-trip safety) of various values. -- To ensure we're testing what we think we're testing, start with -- float values specified by bit patterns (as a useful side effect, -- this means we'll fail on non-IEEE platforms).
create type xfloat4; create function xfloat4in(cstring) returns xfloat4 immutable strict
language internal as'int4in'; create function xfloat4out(xfloat4) returns cstring immutable strict
language internal as'int4out'; create type xfloat4 (input = xfloat4in, output = xfloat4out, like = float4); create cast (xfloat4 asfloat4) without function; create cast (float4as xfloat4) without function; create cast (xfloat4 asinteger) without function; create cast (integeras xfloat4) without function;
-- float4: seeeeeee emmmmmmm mmmmmmmm mmmmmmmm
-- we don't care to assume the platform's strtod() handles subnormals -- correctly; those are "use at your own risk". However we do test -- subnormal outputs, since those are under our control.
with testdata(bits) as (values -- small subnormals
(x'00000001'),
(x'00000002'), (x'00000003'),
(x'00000010'), (x'00000011'), (x'00000100'), (x'00000101'),
(x'00004000'), (x'00004001'), (x'00080000'), (x'00080001'), -- stress values
(x'0053c4f4'), -- 7693e-42
(x'006c85c4'), -- 996622e-44
(x'0041ca76'), -- 60419369e-46
(x'004b7678'), -- 6930161142e-48 -- taken from upstream testsuite
(x'00000007'),
(x'00424fe2'), -- borderline between subnormal and normal
(x'007ffff0'), (x'007ffff1'), (x'007ffffe'), (x'007fffff')) select float4send(flt) as ibits,
flt from (select bits::integer::xfloat4::float4as flt from testdata
offset 0) s;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.