Did I find the right examples for you? yes no

# pypy.rlib.rarithmetic.isnan

All Samples(22)  |  Call(13)  |  Derive(0)  |  Import(9)

```
import math
from pypy.rlib.rarithmetic import r_longlong, isinf, isnan, INFINITY, NAN

def pack_float(result, number, size, bigendian):
```
```        prec = 52

if isnan(number):
sign = 0x80
man, e = 1.5, bias + 1
```

```    In RPython, floats cannot be used with ints in dicts, anyway.
"""
from pypy.rlib.rarithmetic import intmask, isinf, isnan
if isinf(f):
if f < 0.0:
return -271828
else:
return 314159
elif isnan(f):
```

```"""
String formatting routines.
"""
from pypy.rlib.unroll import unrolling_iterable
from pypy.rlib.rarithmetic import ovfcheck, formatd_overflow, isnan, isinf
```
```    def format_float(self, w_value, char):
space = self.space
x = space.float_w(maybe_float(space, w_value))
if isnan(x):
r = 'nan'
```

```import sys
from pypy.rlib.objectmodel import Symbolic, ComputedIntSymbolic
from pypy.rlib.objectmodel import CDefinedIntSymbolic
from pypy.rlib.rarithmetic import r_longlong, isinf, isnan
from pypy.rpython.lltypesystem.lltype import *
```
```        else:
return '(-Py_HUGE_VAL)'
elif isnan(value):
return '(Py_HUGE_VAL/Py_HUGE_VAL)'
else:
```
```        else:
return '((float)-Py_HUGE_VAL)'
elif isnan(value):
# XXX are these expressions ok?
return '((float)(Py_HUGE_VAL/Py_HUGE_VAL))'
```

```from pypy.rpython.ootypesystem import ootype
from pypy.rlib.objectmodel import CDefinedIntSymbolic
from pypy.rlib.rarithmetic import isnan, isinf
from pypy.translator.oosupport.constant import push_constant
import pypy.translator.jvm.typesystem as jvm
```
```    def _push_double_constant(self, value):
if isnan(value):
elif isinf(value):
if value > 0: jvm.DOUBLEPOSINF.load(self)
```

```from pypy.rpython.lltypesystem.lltype import Signed, Unsigned, Void, Bool, Float
from pypy.rpython.lltypesystem.lltype import SignedLongLong, UnsignedLongLong
from pypy.rpython.lltypesystem import rffi
from pypy.rlib.objectmodel import CDefinedIntSymbolic
from pypy.rlib.rarithmetic import isnan, isinf
```
```                else:
ilasm.opcode('ldc.r8', '(00 00 00 00 00 00 f0 7f)')
elif isnan(value):
ilasm.opcode('ldc.r8', '(00 00 00 00 00 00 f8 ff)')
else:
```

```from pypy.translator.c.support import c_char_array_constant, barebonearray
from pypy.translator.c.primitive import PrimitiveType, name_signed
from pypy.rlib.rarithmetic import isinf, isnan
from pypy.translator.c import extfunc
from pypy.translator.tool.cbuild import ExternalCompilationInfo
```
```            expr = 'NULL /*%s*/' % node.name
node.where_to_copy_me.append('&%s' % access_expr)
elif typeOf(value) == Float and (isinf(value) or isnan(value)):
db.late_initializations.append(('%s' % access_expr, db.get(value)))
expr = '0.0 /* patched later by %sinfinity */' % (
```

```import sys
from pypy.rlib.rstruct.ieee import pack_float, unpack_float
from pypy.rlib.rarithmetic import isinf, isnan

testcases = [
```
```def test_correct_tests():
import struct
for number, size, bigendian, expected in testcases:
if sys.version < (2, 5) and (isinf(number) or isnan(number)):
continue    # 'inf' and 'nan' unsupported in CPython 2.4's struct
```
```        assert struct.pack(fmt, number) == expected
res, = struct.unpack(fmt, expected)
assert (isnan(res) and isnan(number)) or \
res == number or abs(res - number) < 1E-6

```
```        assert len(input) == size
res = unpack_float(input, bigendian)
if isnan(res) and isnan(expected):
pass
else:
```

```import sys