How to get raw representation (as given by hex()) from an Fxp #37
-
Without converting to/from string? I need to convert floats to fixed point and upload them to CUDA memory for computations. All the astype functions convert the actual value and I can't find anything that provides the fixed-point representation. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hello Ani, first let me convert this issue to a discussion. I guess you need get the from fxpmath import Fxp
x = Fxp(0.25, dtype='s8.8')
x.raw() # returns 64 as raw value If my assumption is wrong, please write an example with the desired output. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the reply! That works great for a single value, but I have a 2D numpy array of floats that I want the raw representation for. Is there a way I can get them all in a single copy operation? Iterating element by element is slow. |
Beta Was this translation helpful? Give feedback.
Hello Ani, first let me convert this issue to a discussion.
I guess you need get the
int
value which represents the raw value of the fixed-point. In that case, you can useraw
method.If my assumption is wrong, please write an example with the desired output.