float --> int

Started by Andreas Zeugswetterover 27 years ago2 messages
#1Andreas Zeugswetter
andreas.zeugswetter@telecom.at

Maurice wrote:

Making an int from a float is only defined for "small" values of the float.
So for the general case such a conversion would simply overflow the int,
giving it an undefined value. Does this make sense to you?

This sure sounds good:
select (4.00000 !); -- would work, but
select (4.30000 !); -- would throw a runtime error like
ERROR: float to integer conversion error, value out of range.

Andreas

#2Maurice Gittens
mgittens@gits.nl
In reply to: Andreas Zeugswetter (#1)
Re: [HACKERS] float --> int

-----Original Message-----
From: Andreas Zeugswetter <andreas.zeugswetter@telecom.at>
To: 'hackers@postgresql.org' <hackers@postgreSQL.org>
Date: maandag 11 mei 1998 21:31
Subject: [HACKERS] float --> int

Maurice wrote:

Making an int from a float is only defined for "small" values of the

float.

So for the general case such a conversion would simply overflow the int,
giving it an undefined value. Does this make sense to you?

This sure sounds good:
select (4.00000 !); -- would work, but
select (4.30000 !); -- would throw a runtime error like
ERROR: float to integer conversion error, value out of range.

I agree. I'm just trying to say that the error should be flagged as such.

Maurice