How to Handle <stdfloat>
Types Like std::float64_t
and std::float16_t
in nanobind?
#821
Replies: 4 comments 2 replies
-
Python really just understands doubles, so any other floating point type (including single precision |
Beta Was this translation helpful? Give feedback.
-
As commented above, a Python If you have a NumPy array using I'm interested in this topic, but I don't have time in the short term to work on it. |
Beta Was this translation helpful? Give feedback.
-
Thank you for your reply. I’m considering modifying the code, as shown in this commit ( I would also like to see |
Beta Was this translation helpful? Give feedback.
-
Please try #829 This is intended to support all of |
Beta Was this translation helpful? Give feedback.
-
I am developing a library for quantum computing and am using C++23's
<stdfloat>
types—std::float16_t
,std::float32_t
,std::float64_t
, andstd::bfloat16_t
—to bind my template functions.These types evaluate
std::floating_point_v
astrue
, which leads nanobind to handle them based on their size, treating them as eitherdouble
orfloat
(referring to [this section](nanobind/include/nanobind/nb_cast.h
Line 128 in d7d9d90
However,
std::float64_t
(an alias of_Float64
) anddouble
have the same structure but are distinct types in GCC, which causes the following error:Even if I were to give up on using
std::float64_t
andstd::float32_t
and fallback todouble
andfloat
, I still have no idea how to properly bind 16-bit floating-point types likestd::float16_t
.Does anyone have experience or advice on how to handle this situation effectively?
Beta Was this translation helpful? Give feedback.
All reactions