Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Correct way to emulate single precision floating point in python?

What's the best way to emulate single-precision floating point in python? (Or other floating point formats for that matter?) Just use ctypes?

like image 315
Ryan Avatar asked Feb 09 '10 20:02

Ryan


People also ask

How do you represent a floating point in Python?

The float type in Python represents the floating point number. Float is used to represent real numbers and is written with a decimal point dividing the integer and fractional parts. For example, 97.98, 32.3+e18, -32.54e100 all are floating point numbers.

How do you represent a single-precision?

The format of IEEE single-precision floating-point standard representation requires 23 fraction bits F, 8 exponent bits E, and 1 sign bit S, with a total of 32 bits for each word. F is the mantissa in 2's complement positive binary fraction represented from bit 0 to bit 22.


1 Answers

numpy has a float32 type.

like image 132
Ignacio Vazquez-Abrams Avatar answered Sep 18 '22 04:09

Ignacio Vazquez-Abrams