Lines Matching defs:fromHex
967 fromHex = float.fromhex
970 MAX = fromHex('0x.fffffffffffff8p+1024') # max normal
971 MIN = fromHex('0x1p-1022') # min normal
972 TINY = fromHex('0x0.0000000000001p-1022') # min subnormal
973 EPS = fromHex('0x0.0000000000001p0') # diff between 1.0 and next float up
1047 result = fromHex(x)
1051 self.fail('Expected float.fromhex(%r) to raise ValueError; '
1077 got = fromHex(lead + inp + trail)
1088 self.identical(fromHex('inf'), INF)
1089 self.identical(fromHex('+Inf'), INF)
1090 self.identical(fromHex('-INF'), -INF)
1091 self.identical(fromHex('iNf'), INF)
1092 self.identical(fromHex('Infinity'), INF)
1093 self.identical(fromHex('+INFINITY'), INF)
1094 self.identical(fromHex('-infinity'), -INF)
1095 self.identical(fromHex('-iNFiNitY'), -INF)
1098 self.identical(fromHex('nan'), NAN)
1099 self.identical(fromHex('+NaN'), NAN)
1100 self.identical(fromHex('-NaN'), NAN)
1101 self.identical(fromHex('-nAN'), NAN)
1104 self.identical(fromHex('1'), 1.0)
1105 self.identical(fromHex('+1'), 1.0)
1106 self.identical(fromHex('1.'), 1.0)
1107 self.identical(fromHex('1.0'), 1.0)
1108 self.identical(fromHex('1.0p0'), 1.0)
1109 self.identical(fromHex('01'), 1.0)
1110 self.identical(fromHex('01.'), 1.0)
1111 self.identical(fromHex('0x1'), 1.0)
1112 self.identical(fromHex('0x1.'), 1.0)
1113 self.identical(fromHex('0x1.0'), 1.0)
1114 self.identical(fromHex('+0x1.0'), 1.0)
1115 self.identical(fromHex('0x1p0'), 1.0)
1116 self.identical(fromHex('0X1p0'), 1.0)
1117 self.identical(fromHex('0X1P0'), 1.0)
1118 self.identical(fromHex('0x1P0'), 1.0)
1119 self.identical(fromHex('0x1.p0'), 1.0)
1120 self.identical(fromHex('0x1.0p0'), 1.0)
1121 self.identical(fromHex('0x.1p4'), 1.0)
1122 self.identical(fromHex('0x.1p04'), 1.0)
1123 self.identical(fromHex('0x.1p004'), 1.0)
1124 self.identical(fromHex('0x1p+0'), 1.0)
1125 self.identical(fromHex('0x1P-0'), 1.0)
1126 self.identical(fromHex('+0x1p0'), 1.0)
1127 self.identical(fromHex('0x01p0'), 1.0)
1128 self.identical(fromHex('0x1p00'), 1.0)
1129 self.identical(fromHex(u'0x1p0'), 1.0)
1130 self.identical(fromHex(' 0x1p0 '), 1.0)
1131 self.identical(fromHex('\n 0x1p0'), 1.0)
1132 self.identical(fromHex('0x1p0 \t'), 1.0)
1133 self.identical(fromHex('0xap0'), 10.0)
1134 self.identical(fromHex('0xAp0'), 10.0)
1135 self.identical(fromHex('0xaP0'), 10.0)
1136 self.identical(fromHex('0xAP0'), 10.0)
1137 self.identical(fromHex('0xbep0'), 190.0)
1138 self.identical(fromHex('0xBep0'), 190.0)
1139 self.identical(fromHex('0xbEp0'), 190.0)
1140 self.identical(fromHex('0XBE0P-4'), 190.0)
1141 self.identical(fromHex('0xBEp0'), 190.0)
1142 self.identical(fromHex('0xB.Ep4'), 190.0)
1143 self.identical(fromHex('0x.BEp8'), 190.0)
1144 self.identical(fromHex('0x.0BEp12'), 190.0)
1147 pi = fromHex('0x1.921fb54442d18p1')
1148 self.identical(fromHex('0x.006487ed5110b46p11'), pi)
1149 self.identical(fromHex('0x.00c90fdaa22168cp10'), pi)
1150 self.identical(fromHex('0x.01921fb54442d18p9'), pi)
1151 self.identical(fromHex('0x.03243f6a8885a3p8'), pi)
1152 self.identical(fromHex('0x.06487ed5110b46p7'), pi)
1153 self.identical(fromHex('0x.0c90fdaa22168cp6'), pi)
1154 self.identical(fromHex('0x.1921fb54442d18p5'), pi)
1155 self.identical(fromHex('0x.3243f6a8885a3p4'), pi)
1156 self.identical(fromHex('0x.6487ed5110b46p3'), pi)
1157 self.identical(fromHex('0x.c90fdaa22168cp2'), pi)
1158 fromHex('0x1.921fb54442d18p1'), pi)
1159 self.identical(fromHex('0x3.243f6a8885a3p0'), pi)
1160 self.identical(fromHex('0x6.487ed5110b46p-1'), pi)
1161 self.identical(fromHex('0xc.90fdaa22168cp-2'), pi)
1162 self.identical(fromHex('0x19.21fb54442d18p-3'), pi)
1163 self.identical(fromHex('0x32.43f6a8885a3p-4'), pi)
1164 self.identical(fromHex('0x64.87ed5110b46p-5'), pi)
1165 self.identical(fromHex('0xc9.0fdaa22168cp-6'), pi)
1166 self.identical(fromHex('0x192.1fb54442d18p-7'), pi)
1167 self.identical(fromHex('0x324.3f6a8885a3p-8'), pi)
1168 self.identical(fromHex('0x648.7ed5110b46p-9'), pi)
1169 self.identical(fromHex('0xc90.fdaa22168cp-10'), pi)
1170 self.identical(fromHex('0x1921.fb54442d18p-11'), pi)
1172 self.identical(fromHex('0x1921fb54442d1.8p-47'), pi)
1173 self.identical(fromHex('0x3243f6a8885a3p-48'), pi)
1174 self.identical(fromHex('0x6487ed5110b46p-49'), pi)
1175 self.identical(fromHex('0xc90fdaa22168cp-50'), pi)
1176 self.identical(fromHex('0x1921fb54442d18p-51'), pi)
1177 self.identical(fromHex('0x3243f6a8885a30p-52'), pi)
1178 self.identical(fromHex('0x6487ed5110b460p-53'), pi)
1179 self.identical(fromHex('0xc90fdaa22168c0p-54'), pi)
1180 self.identical(fromHex('0x1921fb54442d180p-55'), pi)
1184 self.assertRaises(OverflowError, fromHex, '-0x1p1024')
1185 self.assertRaises(OverflowError, fromHex, '0x1p+1025')
1186 self.assertRaises(OverflowError, fromHex, '+0X1p1030')
1187 self.assertRaises(OverflowError, fromHex, '-0x1p+1100')
1188 self.assertRaises(OverflowError, fromHex, '0X1p123456789123456789')
1189 self.assertRaises(OverflowError, fromHex, '+0X.8p+1025')
1190 self.assertRaises(OverflowError, fromHex, '+0x0.8p1025')
1191 self.assertRaises(OverflowError, fromHex, '-0x0.4p1026')
1192 self.assertRaises(OverflowError, fromHex, '0X2p+1023')
1193 self.assertRaises(OverflowError, fromHex, '0x2.p1023')
1194 self.assertRaises(OverflowError, fromHex, '-0x2.0p+1023')
1195 self.assertRaises(OverflowError, fromHex, '+0X4p+1022')
1196 self.assertRaises(OverflowError, fromHex, '0x1.ffffffffffffffp+1023')
1197 self.assertRaises(OverflowError, fromHex, '-0X1.fffffffffffff9p1023')
1198 self.assertRaises(OverflowError, fromHex, '0X1.fffffffffffff8p1023')
1199 self.assertRaises(OverflowError, fromHex, '+0x3.fffffffffffffp1022')
1200 self.assertRaises(OverflowError, fromHex, '0x3fffffffffffffp+970')
1201 self.assertRaises(OverflowError, fromHex, '0x10000000000000000p960')
1202 self.assertRaises(OverflowError, fromHex, '-0Xffffffffffffffffp960')
1205 self.identical(fromHex('+0x1.fffffffffffffp+1023'), MAX)
1206 self.identical(fromHex('-0X1.fffffffffffff7p1023'), -MAX)
1207 self.identical(fromHex('0X1.fffffffffffff7fffffffffffffp1023'), MAX)
1210 self.identical(fromHex('0x0p0'), 0.0)
1211 self.identical(fromHex('0x0p1000'), 0.0)
1212 self.identical(fromHex('-0x0p1023'), -0.0)
1213 self.identical(fromHex('0X0p1024'), 0.0)
1214 self.identical(fromHex('-0x0p1025'), -0.0)
1215 self.identical(fromHex('0X0p2000'), 0.0)
1216 self.identical(fromHex('0x0p123456789123456789'), 0.0)
1217 self.identical(fromHex('-0X0p-0'), -0.0)
1218 self.identical(fromHex('-0X0p-1000'), -0.0)
1219 self.identical(fromHex('0x0p-1023'), 0.0)
1220 self.identical(fromHex('-0X0p-1024'), -0.0)
1221 self.identical(fromHex('-0x0p-1025'), -0.0)
1222 self.identical(fromHex('-0x0p-1072'), -0.0)
1223 self.identical(fromHex('0X0p-1073'), 0.0)
1224 self.identical(fromHex('-0x0p-1074'), -0.0)
1225 self.identical(fromHex('0x0p-1075'), 0.0)
1226 self.identical(fromHex('0X0p-1076'), 0.0)
1227 self.identical(fromHex('-0X0p-2000'), -0.0)
1228 self.identical(fromHex('-0x0p-123456789123456789'), -0.0)
1231 self.identical(fromHex('0X1p-1075'), 0.0)
1232 self.identical(fromHex('-0X1p-1075'), -0.0)
1233 self.identical(fromHex('-0x1p-123456789123456789'), -0.0)
1234 self.identical(fromHex('0x1.00000000000000001p-1075'), TINY)
1235 self.identical(fromHex('-0x1.1p-1075'), -TINY)
1236 self.identical(fromHex('0x1.fffffffffffffffffp-1075'), TINY)
1239 self.identical(fromHex('0x1p-1076'), 0.0)
1240 self.identical(fromHex('0X2p-1076'), 0.0)
1241 self.identical(fromHex('0X3p-1076'), TINY)
1242 self.identical(fromHex('0x4p-1076'), TINY)
1243 self.identical(fromHex('0X5p-1076'), TINY)
1244 self.identical(fromHex('0X6p-1076'), 2*TINY)
1245 self.identical(fromHex('0x7p-1076'), 2*TINY)
1246 self.identical(fromHex('0X8p-1076'), 2*TINY)
1247 self.identical(fromHex('0X9p-1076'), 2*TINY)
1248 self.identical(fromHex('0xap-1076'), 2*TINY)
1249 self.identical(fromHex('0Xbp-1076'), 3*TINY)
1250 self.identical(fromHex('0xcp-1076'), 3*TINY)
1251 self.identical(fromHex('0Xdp-1076'), 3*TINY)
1252 self.identical(fromHex('0Xep-1076'), 4*TINY)
1253 self.identical(fromHex('0xfp-1076'), 4*TINY)
1254 self.identical(fromHex('0x10p-1076'), 4*TINY)
1255 self.identical(fromHex('-0x1p-1076'), -0.0)
1256 self.identical(fromHex('-0X2p-1076'), -0.0)
1257 self.identical(fromHex('-0x3p-1076'), -TINY)
1258 self.identical(fromHex('-0X4p-1076'), -TINY)
1259 self.identical(fromHex('-0x5p-1076'), -TINY)
1260 self.identical(fromHex('-0x6p-1076'), -2*TINY)
1261 self.identical(fromHex('-0X7p-1076'), -2*TINY)
1262 self.identical(fromHex('-0X8p-1076'), -2*TINY)
1263 self.identical(fromHex('-0X9p-1076'), -2*TINY)
1264 self.identical(fromHex('-0Xap-1076'), -2*TINY)
1265 self.identical(fromHex('-0xbp-1076'), -3*TINY)
1266 self.identical(fromHex('-0xcp-1076'), -3*TINY)
1267 self.identical(fromHex('-0Xdp-1076'), -3*TINY)
1268 self.identical(fromHex('-0xep-1076'), -4*TINY)
1269 self.identical(fromHex('-0Xfp-1076'), -4*TINY)
1270 self.identical(fromHex('-0X10p-1076'), -4*TINY)
1273 self.identical(fromHex('0x0.ffffffffffffd6p-1022'), MIN-3*TINY)
1274 self.identical(fromHex('0x0.ffffffffffffd8p-1022'), MIN-2*TINY)
1275 self.identical(fromHex('0x0.ffffffffffffdap-1022'), MIN-2*TINY)
1276 self.identical(fromHex('0x0.ffffffffffffdcp-1022'), MIN-2*TINY)
1277 self.identical(fromHex('0x0.ffffffffffffdep-1022'), MIN-2*TINY)
1278 self.identical(fromHex('0x0.ffffffffffffe0p-1022'), MIN-2*TINY)
1279 self.identical(fromHex('0x0.ffffffffffffe2p-1022'), MIN-2*TINY)
1280 self.identical(fromHex('0x0.ffffffffffffe4p-1022'), MIN-2*TINY)
1281 self.identical(fromHex('0x0.ffffffffffffe6p-1022'), MIN-2*TINY)
1282 self.identical(fromHex('0x0.ffffffffffffe8p-1022'), MIN-2*TINY)
1283 self.identical(fromHex('0x0.ffffffffffffeap-1022'), MIN-TINY)
1284 self.identical(fromHex('0x0.ffffffffffffecp-1022'), MIN-TINY)
1285 self.identical(fromHex('0x0.ffffffffffffeep-1022'), MIN-TINY)
1286 self.identical(fromHex('0x0.fffffffffffff0p-1022'), MIN-TINY)
1287 self.identical(fromHex('0x0.fffffffffffff2p-1022'), MIN-TINY)
1288 self.identical(fromHex('0x0.fffffffffffff4p-1022'), MIN-TINY)
1289 self.identical(fromHex('0x0.fffffffffffff6p-1022'), MIN-TINY)
1290 self.identical(fromHex('0x0.fffffffffffff8p-1022'), MIN)
1291 self.identical(fromHex('0x0.fffffffffffffap-1022'), MIN)
1292 self.identical(fromHex('0x0.fffffffffffffcp-1022'), MIN)
1293 self.identical(fromHex('0x0.fffffffffffffep-1022'), MIN)
1294 self.identical(fromHex('0x1.00000000000000p-1022'), MIN)
1295 self.identical(fromHex('0x1.00000000000002p-1022'), MIN)
1296 self.identical(fromHex('0x1.00000000000004p-1022'), MIN)
1297 self.identical(fromHex('0x1.00000000000006p-1022'), MIN)
1298 self.identical(fromHex('0x1.00000000000008p-1022'), MIN)
1299 self.identical(fromHex('0x1.0000000000000ap-1022'), MIN+TINY)
1300 self.identical(fromHex('0x1.0000000000000cp-1022'), MIN+TINY)
1301 self.identical(fromHex('0x1.0000000000000ep-1022'), MIN+TINY)
1302 self.identical(fromHex('0x1.00000000000010p-1022'), MIN+TINY)
1303 self.identical(fromHex('0x1.00000000000012p-1022'), MIN+TINY)
1304 self.identical(fromHex('0x1.00000000000014p-1022'), MIN+TINY)
1305 self.identical(fromHex('0x1.00000000000016p-1022'), MIN+TINY)
1306 self.identical(fromHex('0x1.00000000000018p-1022'), MIN+2*TINY)
1309 self.identical(fromHex('0x0.fffffffffffff0p0'), 1.0-EPS)
1310 self.identical(fromHex('0x0.fffffffffffff1p0'), 1.0-EPS)
1311 self.identical(fromHex('0X0.fffffffffffff2p0'), 1.0-EPS)
1312 self.identical(fromHex('0x0.fffffffffffff3p0'), 1.0-EPS)
1313 self.identical(fromHex('0X0.fffffffffffff4p0'), 1.0-EPS)
1314 self.identical(fromHex('0X0.fffffffffffff5p0'), 1.0-EPS/2)
1315 self.identical(fromHex('0X0.fffffffffffff6p0'), 1.0-EPS/2)
1316 self.identical(fromHex('0x0.fffffffffffff7p0'), 1.0-EPS/2)
1317 self.identical(fromHex('0x0.fffffffffffff8p0'), 1.0-EPS/2)
1318 self.identical(fromHex('0X0.fffffffffffff9p0'), 1.0-EPS/2)
1319 self.identical(fromHex('0X0.fffffffffffffap0'), 1.0-EPS/2)
1320 self.identical(fromHex('0x0.fffffffffffffbp0'), 1.0-EPS/2)
1321 self.identical(fromHex('0X0.fffffffffffffcp0'), 1.0)
1322 self.identical(fromHex('0x0.fffffffffffffdp0'), 1.0)
1323 self.identical(fromHex('0X0.fffffffffffffep0'), 1.0)
1324 self.identical(fromHex('0x0.ffffffffffffffp0'), 1.0)
1325 self.identical(fromHex('0X1.00000000000000p0'), 1.0)
1326 self.identical(fromHex('0X1.00000000000001p0'), 1.0)
1327 self.identical(fromHex('0x1.00000000000002p0'), 1.0)
1328 self.identical(fromHex('0X1.00000000000003p0'), 1.0)
1329 self.identical(fromHex('0x1.00000000000004p0'), 1.0)
1330 self.identical(fromHex('0X1.00000000000005p0'), 1.0)
1331 self.identical(fromHex('0X1.00000000000006p0'), 1.0)
1332 self.identical(fromHex('0X1.00000000000007p0'), 1.0)
1333 self.identical(fromHex('0x1.00000000000007ffffffffffffffffffffp0'),
1335 self.identical(fromHex('0x1.00000000000008p0'), 1.0)
1336 self.identical(fromHex('0x1.00000000000008000000000000000001p0'),
1338 self.identical(fromHex('0X1.00000000000009p0'), 1.0+EPS)
1339 self.identical(fromHex('0x1.0000000000000ap0'), 1.0+EPS)
1340 self.identical(fromHex('0x1.0000000000000bp0'), 1.0+EPS)
1341 self.identical(fromHex('0X1.0000000000000cp0'), 1.0+EPS)
1342 self.identical(fromHex('0x1.0000000000000dp0'), 1.0+EPS)
1343 self.identical(fromHex('0x1.0000000000000ep0'), 1.0+EPS)
1344 self.identical(fromHex('0X1.0000000000000fp0'), 1.0+EPS)
1345 self.identical(fromHex('0x1.00000000000010p0'), 1.0+EPS)
1346 self.identical(fromHex('0X1.00000000000011p0'), 1.0+EPS)
1347 self.identical(fromHex('0x1.00000000000012p0'), 1.0+EPS)
1348 self.identical(fromHex('0X1.00000000000013p0'), 1.0+EPS)
1349 self.identical(fromHex('0X1.00000000000014p0'), 1.0+EPS)
1350 self.identical(fromHex('0x1.00000000000015p0'), 1.0+EPS)
1351 self.identical(fromHex('0x1.00000000000016p0'), 1.0+EPS)
1352 self.identical(fromHex('0X1.00000000000017p0'), 1.0+EPS)
1353 self.identical(fromHex('0x1.00000000000017ffffffffffffffffffffp0'),
1355 self.identical(fromHex('0x1.00000000000018p0'), 1.0+2*EPS)
1356 self.identical(fromHex('0X1.00000000000018000000000000000001p0'),
1358 self.identical(fromHex('0x1.00000000000019p0'), 1.0+2*EPS)
1359 self.identical(fromHex('0X1.0000000000001ap0'), 1.0+2*EPS)
1360 self.identical(fromHex('0X1.0000000000001bp0'), 1.0+2*EPS)
1361 self.identical(fromHex('0x1.0000000000001cp0'), 1.0+2*EPS)
1362 self.identical(fromHex('0x1.0000000000001dp0'), 1.0+2*EPS)
1363 self.identical(fromHex('0x1.0000000000001ep0'), 1.0+2*EPS)
1364 self.identical(fromHex('0X1.0000000000001fp0'), 1.0+2*EPS)
1365 self.identical(fromHex('0x1.00000000000020p0'), 1.0+2*EPS)
1369 return fromHex(toHex(x))
1375 # fromHex(toHex(x)) should exactly recover x, for any non-NaN float x.
1386 self.identical(x, fromHex(toHex(x)))