Converting numpy float64 of python float to Decimal is not the same (get rounded in numpy case)
Environment
- Pythonnet version: '2.5.1'
- Python version: 3.8.12
- Operating System: Win10
- .NET Runtime: 4.8.4470.0
- numpy version: 1.21.4
Details
- Describe what you were trying to get done.
I had to convert floats to Decimal but somehow the current Double I got out of Decimal when looking at it using ToDouble would give me only the round part of the double. I figured that my floats were not native python but numpy float64 . This issue happens only with numpy floats..
- What commands did you run to trigger this issue? If you can provide a
Minimal, Complete, and Verifiable example
this will help us understand the issue.
import clr from System import Decimal import numpy as np d= 45.5 assert d == np.array([d])[0] # should be fine assert Decimal(d) == Decimal(np.array([d])[0]) # assertion error