Lines Matching full:fromhex
1021 fromHex = float.fromhex
1024 MAX = fromHex('0x.fffffffffffff8p+1024') # max normal
1025 MIN = fromHex('0x1p-1022') # min normal
1026 TINY = fromHex('0x0.0000000000001p-1022') # min subnormal
1027 EPS = fromHex('0x0.0000000000001p0') # diff between 1.0 and next float up
1101 result = fromHex(x)
1105 self.fail('Expected float.fromhex(%r) to raise ValueError; '
1131 got = fromHex(lead + inp + trail)
1142 self.identical(fromHex('inf'), INF)
1143 self.identical(fromHex('+Inf'), INF)
1144 self.identical(fromHex('-INF'), -INF)
1145 self.identical(fromHex('iNf'), INF)
1146 self.identical(fromHex('Infinity'), INF)
1147 self.identical(fromHex('+INFINITY'), INF)
1148 self.identical(fromHex('-infinity'), -INF)
1149 self.identical(fromHex('-iNFiNitY'), -INF)
1152 self.identical(fromHex('nan'), NAN)
1153 self.identical(fromHex('+NaN'), NAN)
1154 self.identical(fromHex('-NaN'), NAN)
1155 self.identical(fromHex('-nAN'), NAN)
1158 self.identical(fromHex('1'), 1.0)
1159 self.identical(fromHex('+1'), 1.0)
1160 self.identical(fromHex('1.'), 1.0)
1161 self.identical(fromHex('1.0'), 1.0)
1162 self.identical(fromHex('1.0p0'), 1.0)
1163 self.identical(fromHex('01'), 1.0)
1164 self.identical(fromHex('01.'), 1.0)
1165 self.identical(fromHex('0x1'), 1.0)
1166 self.identical(fromHex('0x1.'), 1.0)
1167 self.identical(fromHex('0x1.0'), 1.0)
1168 self.identical(fromHex
1169 self.identical(fromHex('0x1p0'), 1.0)
1170 self.identical(fromHex('0X1p0'), 1.0)
1171 self.identical(fromHex('0X1P0'), 1.0)
1172 self.identical(fromHex('0x1P0'), 1.0)
1173 self.identical(fromHex('0x1.p0'), 1.0)
1174 self.identical(fromHex('0x1.0p0'), 1.0)
1175 self.identical(fromHex('0x.1p4'), 1.0)
1176 self.identical(fromHex('0x.1p04'), 1.0)
1177 self.identical(fromHex('0x.1p004'), 1.0)
1178 self.identical(fromHex('0x1p+0'), 1.0)
1179 self.identical(fromHex('0x1P-0'), 1.0)
1180 self.identical(fromHex('+0x1p0'), 1.0)
1181 self.identical(fromHex('0x01p0'), 1.0)
1182 self.identical(fromHex('0x1p00'), 1.0)
1183 self.identical(fromHex(u'0x1p0'), 1.0)
1184 self.identical(fromHex(' 0x1p0 '), 1.0)
1185 self.identical(fromHex('\n 0x1p0'), 1.0)
1186 self.identical(fromHex('0x1p0 \t'), 1.0)
1187 self.identical(fromHex('0xap0'), 10.0)
1188 self.identical(fromHex('0xAp0'), 10.0)
1189 self.identical(fromHex('0xaP0'), 10.0)
1190 self.identical(fromHex('0xAP0'), 10.0)
1191 self.identical(fromHex('0xbep0'), 190.0)
1192 self.identical(fromHex('0xBep0'), 190.0)
1193 self.identical(fromHex('0xbEp0'), 190.0)
1194 self.identical(fromHex('0XBE0P-4'), 190.0)
1195 self.identical(fromHex('0xBEp0'), 190.0)
1196 self.identical(fromHex('0xB.Ep4'), 190.0)
1197 self.identical(fromHex('0x.BEp8'), 190.0)
1198 self.identical(fromHex('0x.0BEp12'), 190.0)
1201 pi = fromHex('0x1.921fb54442d18p1')
1202 self.identical(fromHex('0x.006487ed5110b46p11'), pi)
1203 self.identical(fromHex('0x.00c90fdaa22168cp10'), pi)
1204 self.identical(fromHex('0x.01921fb54442d18p9'), pi)
1205 self.identical(fromHex('0x.03243f6a8885a3p8'), pi)
1206 self.identical(fromHex('0x.06487ed5110b46p7'), pi)
1207 self.identical(fromHex('0x.0c90fdaa22168cp6'), pi)
1208 self.identical(fromHex('0x.1921fb54442d18p5'), pi)
1209 self.identical(fromHex('0x.3243f6a8885a3p4'), pi)
1210 self.identical(fromHex('0x.6487ed5110b46p3'), pi)
1211 self.identical(fromHex('0x.c90fdaa22168cp2'), pi)
1212 self.identical(fromHex('0x1.921fb54442d18p1'), pi)
1213 self.identical(fromHex('0x3.243f6a8885a3p0'), pi)
1214 self.identical(fromHex('0x6.487ed5110b46p-1'), pi)
1215 self.identical(fromHex('0xc.90fdaa22168cp-2'), pi)
1216 self.identical(fromHex('0x19.21fb54442d18p-3'), pi)
1217 self.identical(fromHex('0x32.43f6a8885a3p-4'), pi)
1218 self.identical(fromHex('0x64.87ed5110b46p-5'), pi)
1219 self.identical(fromHex('0xc9.0fdaa22168cp-6'), pi)
1220 self.identical(fromHex('0x192.1fb54442d18p-7'), pi)
1221 self.identical(fromHex('0x324.3f6a8885a3p-8'), pi)
1222 self.identical(fromHex('0x648.7ed5110b46p-9'), pi)
1223 self.identical(fromHex('0xc90.fdaa22168cp-10'), pi)
1224 self.identical(fromHex('0x1921.fb54442d18p-11'), pi)
1226 self.identical(fromHex('0x1921fb54442d1.8p-47'), pi)
1227 self.identical(fromHex('0x3243f6a8885a3p-48'), pi)
1228 self.identical(fromHex('0x6487ed5110b46p-49'), pi)
1229 self.identical(fromHex('0xc90fdaa22168cp-50'), pi)
1230 self.identical(fromHex('0x1921fb54442d18p-51'), pi)
1231 self.identical(fromHex('0x3243f6a8885a30p-52'), pi)
1232 self.identical(fromHex('0x6487ed5110b460p-53'), pi)
1233 self.identical(fromHex('0xc90fdaa22168c0p-54'), pi)
1234 self.identical(fromHex('0x1921fb54442d180p-55'), pi)
1238 self.assertRaises(OverflowError, fromHex, '-0x1p1024')
1239 self.assertRaises(OverflowError, fromHex, '0x1p+1025')
1240 self.assertRaises(OverflowError, fromHex, '+0X1p1030')
1241 self.assertRaises(OverflowError, fromHex, '-0x1p+1100')
1242 self.assertRaises(OverflowError, fromHex, '0X1p123456789123456789')
1243 self.assertRaises(OverflowError, fromHex, '+0X.8p+1025')
1244 self.assertRaises(OverflowError, fromHex, '+0x0.8p1025')
1245 self.assertRaises(OverflowError, fromHex, '-0x0.4p1026')
1246 self.assertRaises(OverflowError, fromHex, '0X2p+1023')
1247 self.assertRaises(OverflowError, fromHex, '0x2.p1023')
1248 self.assertRaises(OverflowError, fromHex, '-0x2.0p+1023')
1249 self.assertRaises(OverflowError, fromHex, '+0X4p+1022')
1250 self.assertRaises(OverflowError, fromHex, '0x1.ffffffffffffffp+1023')
1251 self.assertRaises(OverflowError, fromHex, '-0X1.fffffffffffff9p1023')
1252 self.assertRaises(OverflowError, fromHex, '0X1.fffffffffffff8p1023')
1253 self.assertRaises(OverflowError, fromHex, '+0x3.fffffffffffffp1022')
1254 self.assertRaises(OverflowError, fromHex, '0x3fffffffffffffp+970')
1255 self.assertRaises(OverflowError, fromHex, '0x10000000000000000p960')
1256 self.assertRaises(OverflowError, fromHex, '-0Xffffffffffffffffp960')
1259 self.identical(fromHex('+0x1.fffffffffffffp+1023'), MAX)
1260 self.identical(fromHex('-0X1.fffffffffffff7p1023'), -MAX)
1261 self.identical(fromHex('0X1.fffffffffffff7fffffffffffffp1023'), MAX)
1264 self.identical(fromHex('0x0p0'), 0.0)
1265 self.identical(fromHex('0x0p1000'), 0.0)
1266 self.identical(fromHex('-0x0p1023'), -0.0)
1267 self.identical(fromHex('0X0p1024'), 0.0)
1268 self.identical(fromHex('-0x0p1025'), -0.0)
1269 self.identical(fromHex('0X0p2000'), 0.0)
1270 self.identical(fromHex('0x0p123456789123456789'), 0.0)
1271 self.identical(fromHex('-0X0p-0'), -0.0)
1272 self.identical(fromHex('-0X0p-1000'), -0.0)
1273 self.identical(fromHex('0x0p-1023'), 0.0)
1274 self.identical(fromHex('-0X0p-1024'), -0.0)
1275 self.identical(fromHex('-0x0p-1025'), -0.0)
1276 self.identical(fromHex('-0x0p-1072'), -0.0)
1277 self.identical(fromHex('0X0p-1073'), 0.0)
1278 self.identical(fromHex('-0x0p-1074'), -0.0)
1279 self.identical(fromHex('0x0p-1075'), 0.0)
1280 self.identical(fromHex('0X0p-1076'), 0.0)
1281 self.identical(fromHex('-0X0p-2000'), -0.0)
1282 self.identical(fromHex('-0x0p-123456789123456789'), -0.0)
1285 self.identical(fromHex('0X1p-1075'), 0.0)
1286 self.identical(fromHex('-0X1p-1075'), -0.0)
1287 self.identical(fromHex('-0x1p-123456789123456789'), -0.0)
1288 self.identical(fromHex('0x1.00000000000000001p-1075'), TINY)
1289 self.identical(fromHex('-0x1.1p-1075'), -TINY)
1290 self.identical(fromHex('0x1.fffffffffffffffffp-1075'), TINY)
1293 self.identical(fromHex('0x1p-1076'), 0.0)
1294 self.identical(fromHex('0X2p-1076'), 0.0)
1295 self.identical(fromHex('0X3p-1076'), TINY)
1296 self.identical(fromHex('0x4p-1076'), TINY)
1297 self.identical(fromHex('0X5p-1076'), TINY)
1298 self.identical(fromHex('0X6p-1076'), 2*TINY)
1299 self.identical(fromHex('0x7p-1076'), 2*TINY)
1300 self.identical(fromHex('0X8p-1076'), 2*TINY)
1301 self.identical(fromHex('0X9p-1076'), 2*TINY)
1302 self.identical(fromHex('0xap-1076'), 2*TINY)
1303 self.identical(fromHex('0Xbp-1076'), 3*TINY)
1304 self.identical(fromHex('0xcp-1076'), 3*TINY)
1305 self.identical(fromHex('0Xdp-1076'), 3*TINY)
1306 self.identical(fromHex('0Xep-1076'), 4*TINY)
1307 self.identical(fromHex('0xfp-1076'), 4*TINY)
1308 self.identical(fromHex('0x10p-1076'), 4*TINY)
1309 self.identical(fromHex('-0x1p-1076'), -0.0)
1310 self.identical(fromHex('-0X2p-1076'), -0.0)
1311 self.identical(fromHex('-0x3p-1076'), -TINY)
1312 self.identical(fromHex('-0X4p-1076'), -TINY)
1313 self.identical(fromHex('-0x5p-1076'), -TINY)
1314 self.identical(fromHex('-0x6p-1076'), -2*TINY)
1315 self.identical(fromHex('-0X7p-1076'), -2*TINY)
1316 self.identical(fromHex('-0X8p-1076'), -2*TINY)
1317 self.identical(fromHex('-0X9p-1076'), -2*TINY)
1318 self.identical(fromHex('-0Xap-1076'), -2*TINY)
1319 self.identical(fromHex('-0xbp-1076'), -3*TINY)
1320 self.identical(fromHex('-0xcp-1076'), -3*TINY)
1321 self.identical(fromHex('-0Xdp-1076'), -3*TINY)
1322 self.identical(fromHex('-0xep-1076'), -4*TINY)
1323 self.identical(fromHex('-0Xfp-1076'), -4*TINY)
1324 self.identical(fromHex('-0X10p-1076'), -4*TINY)
1327 self.identical(fromHex('0x0.ffffffffffffd6p-1022'), MIN-3*TINY)
1328 self.identical(fromHex('0x0.ffffffffffffd8p-1022'), MIN-2*TINY)
1329 self.identical(fromHex('0x0.ffffffffffffdap-1022'), MIN-2*TINY)
1330 self.identical(fromHex('0x0.ffffffffffffdcp-1022'), MIN-2*TINY)
1331 self.identical(fromHex('0x0.ffffffffffffdep-1022'), MIN-2*TINY)
1332 self.identical(fromHex('0x0.ffffffffffffe0p-1022'), MIN-2*TINY)
1333 self.identical(fromHex('0x0.ffffffffffffe2p-1022'), MIN-2*TINY)
1334 self.identical(fromHex('0x0.ffffffffffffe4p-1022'), MIN-2*TINY)
1335 self.identical(fromHex('0x0.ffffffffffffe6p-1022'), MIN-2*TINY)
1336 self.identical(fromHex('0x0.ffffffffffffe8p-1022'), MIN-2*TINY)
1337 self.identical(fromHex('0x0.ffffffffffffeap-1022'), MIN-TINY)
1338 self.identical(fromHex('0x0.ffffffffffffecp-1022'), MIN-TINY)
1339 self.identical(fromHex('0x0.ffffffffffffeep-1022'), MIN-TINY)
1340 self.identical(fromHex('0x0.fffffffffffff0p-1022'), MIN-TINY)
1341 self.identical(fromHex('0x0.fffffffffffff2p-1022'), MIN-TINY)
1342 self.identical(fromHex('0x0.fffffffffffff4p-1022'), MIN-TINY)
1343 self.identical(fromHex('0x0.fffffffffffff6p-1022'), MIN-TINY)
1344 self.identical(fromHex('0x0.fffffffffffff8p-1022'), MIN)
1345 self.identical(fromHex('0x0.fffffffffffffap-1022'), MIN)
1346 self.identical(fromHex('0x0.fffffffffffffcp-1022'), MIN)
1347 self.identical(fromHex('0x0.fffffffffffffep-1022'), MIN)
1348 self.identical(fromHex('0x1.00000000000000p-1022'), MIN)
1349 self.identical(fromHex('0x1.00000000000002p-1022'), MIN)
1350 self.identical(fromHex('0x1.00000000000004p-1022'), MIN)
1351 self.identical(fromHex('0x1.00000000000006p-1022'), MIN)
1352 self.identical(fromHex('0x1.00000000000008p-1022'), MIN)
1353 self.identical(fromHex('0x1.0000000000000ap-1022'), MIN+TINY)
1354 self.identical(fromHex('0x1.0000000000000cp-1022'), MIN+TINY)
1355 self.identical(fromHex('0x1.0000000000000ep-1022'), MIN+TINY)
1356 self.identical(fromHex('0x1.00000000000010p-1022'), MIN+TINY)
1357 self.identical(fromHex('0x1.00000000000012p-1022'), MIN+TINY)
1358 self.identical(fromHex('0x1.00000000000014p-1022'), MIN+TINY)
1359 self.identical(fromHex('0x1.00000000000016p-1022'), MIN+TINY)
1360 self.identical(fromHex('0x1.00000000000018p-1022'), MIN+2*TINY)
1363 self.identical(fromHex('0x0.fffffffffffff0p0'), 1.0-EPS)
1364 self.identical(fromHex('0x0.fffffffffffff1p0'), 1.0-EPS)
1365 self.identical(fromHex('0X0.fffffffffffff2p0'), 1.0-EPS)
1366 self.identical(fromHex('0x0.fffffffffffff3p0'), 1.0-EPS)
1367 self.identical(fromHex('0X0.fffffffffffff4p0'), 1.0-EPS)
1368 self.identical(fromHex('0X0.fffffffffffff5p0'), 1.0-EPS/2)
1369 self.identical(fromHex('0X0.fffffffffffff6p0'), 1.0-EPS/2)
1370 self.identical(fromHex('0x0.fffffffffffff7p0'), 1.0-EPS/2)
1371 self.identical(fromHex('0x0.fffffffffffff8p0'), 1.0-EPS/2)
1372 self.identical(fromHex('0X0.fffffffffffff9p0'), 1.0-EPS/2)
1373 self.identical(fromHex('0X0.fffffffffffffap0'), 1.0-EPS/2)
1374 self.identical(fromHex('0x0.fffffffffffffbp0'), 1.0-EPS/2)
1375 self.identical(fromHex('0X0.fffffffffffffcp0'), 1.0)
1376 self.identical(fromHex('0x0.fffffffffffffdp0'), 1.0)
1377 self.identical(fromHex('0X0.fffffffffffffep0'), 1.0)
1378 self.identical(fromHex('0x0.ffffffffffffffp0'), 1.0)
1379 self.identical(fromHex('0X1.00000000000000p0'), 1.0)
1380 self.identical(fromHex('0X1.00000000000001p0'), 1.0)
1381 self.identical(fromHex('0x1.00000000000002p0'), 1.0)
1382 self.identical(fromHex('0X1.00000000000003p0'), 1.0)
1383 self.identical(fromHex('0x1.00000000000004p0'), 1.0)
1384 self.identical(fromHex('0X1.00000000000005p0'), 1.0)
1385 self.identical(fromHex('0X1.00000000000006p0'), 1.0)
1386 self.identical(fromHex('0X1.00000000000007p0'), 1.0)
1387 self.identical(fromHex('0x1.00000000000007ffffffffffffffffffffp0'),
1389 self.identical(fromHex('0x1.00000000000008p0'), 1.0)
1390 self.identical(fromHex('0x1.00000000000008000000000000000001p0'),
1392 self.identical(fromHex('0X1.00000000000009p0'), 1.0+EPS)
1393 self.identical(fromHex('0x1.0000000000000ap0'), 1.0+EPS)
1394 self.identical(fromHex('0x1.0000000000000bp0'), 1.0+EPS)
1395 self.identical(fromHex('0X1.0000000000000cp0'), 1.0+EPS)
1396 self.identical(fromHex('0x1.0000000000000dp0'), 1.0+EPS)
1397 self.identical(fromHex('0x1.0000000000000ep0'), 1.0+EPS)
1398 self.identical(fromHex('0X1.0000000000000fp0'), 1.0+EPS)
1399 self.identical(fromHex('0x1.00000000000010p0'), 1.0+EPS)
1400 self.identical(fromHex('0X1.00000000000011p0'), 1.0+EPS)
1401 self.identical(fromHex('0x1.00000000000012p0'), 1.0+EPS)
1402 self.identical(fromHex('0X1.00000000000013p0'), 1.0+EPS)
1403 self.identical(fromHex('0X1.00000000000014p0'), 1.0+EPS)
1404 self.identical(fromHex('0x1.00000000000015p0'), 1.0+EPS)
1405 self.identical(fromHex('0x1.00000000000016p0'), 1.0+EPS)
1406 self.identical(fromHex('0X1.00000000000017p0'), 1.0+EPS)
1407 self.identical(fromHex('0x1.00000000000017ffffffffffffffffffffp0'),
1409 self.identical(fromHex('0x1.00000000000018p0'), 1.0+2*EPS)
1410 self.identical(fromHex('0X1.00000000000018000000000000000001p0'),
1412 self.identical(fromHex('0x1.00000000000019p0'), 1.0+2*EPS)
1413 self.identical(fromHex('0X1.0000000000001ap0'), 1.0+2*EPS)
1414 self.identical(fromHex('0X1.0000000000001bp0'), 1.0+2*EPS)
1415 self.identical(fromHex('0x1.0000000000001cp0'), 1.0+2*EPS)
1416 self.identical(fromHex('0x1.0000000000001dp0'), 1.0+2*EPS)
1417 self.identical(fromHex('0x1.0000000000001ep0'), 1.0+2*EPS)
1418 self.identical(fromHex('0X1.0000000000001fp0'), 1.0+2*EPS)
1419 self.identical(fromHex('0x1.00000000000020p0'), 1.0+2*EPS)
1423 return fromHex(toHex(x))
1429 # fromHex(toHex(x)) should exactly recover x, for any non-NaN float x.
1440 self.identical(x, fromHex(toHex(x)))