On this page
ctypes.c_float
Prev: ctypes.c_double_complex | Up: ctypes | Next: ctypes.c_float_complex
Rel: ctypes.addressof, ctypes.alignment, ctypes.ArgumentError, ctypes.Array
Ref: docs.python.org — ctypes.c_float
Tags: #public #python3 #stdlib #ctypes
Import
import ctypes
from ctypes import c_float
Signature & Overview
ctypes.c_float(...)
ctypes.c_float class.
Usage
import ctypes
f = ctypes.c_float(1.5)
assert f.value == 1.5 and ctypes.sizeof(f) == 4
Gotchas
- 32-bit float: Loses precision compared to Python's 64-bit
float(c_double).
REPL Inspect
from ctypes import c_float
help(c_float)
Linked from
Related notes
- tuts/python3/stdlib_module/ctypes/c_double_complex Linked here; links to this page; shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/c_float_complex Linked here; links to this page; shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/ctypes/addressof Linked here; shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/alignment Linked here; shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/ArgumentError Linked here; shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/Array Linked here; shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/BigEndianStructure shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/BigEndianUnion shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/byref shared tags: #ctypes, #stdlib