[Python-Dev] trunc() (original) (raw)
Steve Holden steve at holdenweb.com
Fri Jan 25 21:26:28 CET 2008
- Previous message: [Python-Dev] trunc()
- Next message: [Python-Dev] trunc()
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Antoine Pitrou wrote:
Raymond Hettinger <python rcn.com> writes:
Go ask a dozen people if they are surprised that int(3.7) returns 3. No one will be surprised (even folks who just use Excel or VB). It is foolhardy to be a purist and rage against the existing art:
Well, for what it's worth, here are MySQL's own two cents: mysql> create table t (a int); Query OK, 0 rows affected (0.00 sec) mysql> insert t (a) values (1.4), (1.6), (-1.6), (-1.4); Query OK, 4 rows affected (0.00 sec) Records: 4 Duplicates: 0 Warnings: 0 mysql> select * from t; +------+ | a | +------+ | 1 | | 2 | | -2 | | -1 | +------+ 4 rows in set (0.00 sec) Two points. Firstly, regarding MySQL as authoritative from a standards point of view is bound to lead to trouble, since they have always played fast and loose with the standard for reasons (I suspect) of implementation convenience.
Second, that example isn't making use of the INT() function. I was going to show you result of taking the INT() of a float column containing your test values. That was when I found out that MySQL (5.0.41, anyway) doesn't implement the INT() function. What was I saying about standards?
regards Steve
Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/
- Previous message: [Python-Dev] trunc()
- Next message: [Python-Dev] trunc()
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]