Skip to content

Precision Loss in Numpy Array with Float32 Type #43

@yaliuSW

Description

@yaliuSW

Description:
When using a numpy array with float32 type, I observed a precision loss that causes small increments to be ignored when added to a large base value.

Steps to Reproduce:

import numpy as np

starttime = 1748229500.0
step_secs = 5
dataS_t = np.zeros(10, dtype=np.float32)

dataS_t[1] = starttime + step_secs * 1
dataS_t[2] = starttime + step_secs * 2

print(dataS_t[1])  # Expected: 1748229505.0
print(dataS_t[2])  # Expected: 1748229510.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions