pike.git
/
src
/
operators.c
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/src/operators.c:1:
/* || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information.
-
|| $Id: operators.c,v 1.
207
2006/
03
/
25
12
:
45
:
51
grubba Exp $
+
|| $Id: operators.c,v 1.
208
2006/
04
/
24
11
:
59
:
35
grubba Exp $
*/ #include "global.h" #include <math.h> #include "interpret.h" #include "svalue.h" #include "multiset.h" #include "mapping.h" #include "array.h" #include "stralloc.h"
pike.git/src/operators.c:254:
} } Pike_error("Cast failed, wanted int, got %s\n", get_name_of_type(sp[-1].type)); } } break; case T_FLOAT:
-
{
+
if (
+
#ifdef HAVE_ISINF
+
isinf(sp[-1].u.float_number) ||
+
#endif
+
#ifdef HAVE_ISNAN
+
isnan(sp[-1].u.float_number) ||
+
#endif
+
0)
{
+
Pike_error("Can't cast inifinites or NaN to int.\n");
+
} else {
int i=DO_NOT_WARN((int)(sp[-1].u.float_number)); #ifdef AUTO_BIGNUM if((i < 0 ? -i : i) < floor(fabs(sp[-1].u.float_number))) { /* Note: This includes the case when i = 0x80000000, i.e. the absolute value is not computable. */ convert_stack_top_to_bignum(); return; /* FIXME: OK to return? Cast tests below indicates we have to do this, at least for now... /Noring */ /* Yes, it is ok to return, it is actually an optimization :)