Skip to content

Converting numpy float64 of python float to Decimal is not the same (get rounded in numpy case) #1833

@seb5g

Description

@seb5g

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..

    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 
    

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions