Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

NumPy · Type Alias

np.float32

np.float32 is an alias for NumPy’s single scalar type. It represents a 32-bit single-precision floating-point value compatible with C float.

How it works

np.float32 is an alias for NumPy’s single scalar type. It represents a 32-bit floating-point value and can be used as a dtype when constructing arrays or as a callable to create a scalar.

Syntax

numpy.float32[source]

Key points

  • np.float32 is an alias of the NumPy single scalar type.
  • It is a single-precision floating-point scalar compatible with C float.
  • The representation has 32 bits: one sign bit, eight exponent bits, and 23 mantissa bits.
  • The canonical name is numpy.float32; its C-like NumPy name is numpy.single, corresponding to C float.
  • The type is exposed through NumPy’s top-level API and can be used directly as np.float32.

Example: Create float32 values

import numpy as np

values = np.array([1, 2, 3], dtype=np.float32)
scalar = np.float32(0.1)
print(values.dtype)  # float32
print(type(scalar).__name__)  # float32

Creates a float32 array and a single-precision NumPy scalar.

When to use it

Construct a single-precision scalar

Creating a NumPy floating-point scalar from an integer, string, or Python numeric value.

Control an array’s dtype

Specifying the element type during array creation or conversion.

Match C float representation

Interfacing with code or storage formats that require C-compatible single-precision floats.

Interview questions

QWhat is np.float32?

np.float32 is an alias of np.single. The type is a single-precision floating-point type compatible with C float, using 32 bits: one sign bit, eight exponent bits, and 23 mantissa bits.

Follow-up: How would you force an array to use it? Pass dtype=np.float32 to an array-creation function or convert an existing array with .astype(np.float32).

QHow do you use np.float32?

Use np.float32(value) to create a NumPy scalar, or provide dtype=np.float32 when creating an array. The scalar type is available from NumPy’s top-level API.

Follow-up: What should you inspect to verify an array’s representation? Check its .dtype, which reports the array’s NumPy data type.

QHow does np.float32 relate to other names and C types?

np.float32 is the canonical NumPy API name, while np.single is its Python API C-like name. Its corresponding C type is float, and its character code is f.

Follow-up: Why might this type be chosen over the default Python float? It uses a fixed 32-bit representation, which can reduce storage compared with typical 64-bit Python floating-point values.

  • numpy.single
  • numpy.float16
  • numpy.float64
  • numpy.dtype

Source: Scalars. Checked 2026-10-15.