0

How can I cast np.longdouble to mpmath.mpf?

import numpy as np
import mpmath

b = np.longdouble(1.0)
a = mpmath.mpf(b)
print (a)
2
  • does this produce an error? Commented Mar 6, 2023 at 14:36
  • yes, TypeError: cannot create mpf from 1.0 Commented Mar 6, 2023 at 14:55

1 Answer 1

0

You will have to convert the longdouble to np.float64 :

import numpy as np
import mpmath

b = np.longdouble(1.0)
c= np.float64(b)
a = mpmath.mpf(c)
print (a)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.