Numeric - Multiply a byte array by a float.

K

Kamilche

I have a need to multiply all the bytes in a Numeric array, by a
float, such as .9, .8, etc. I can't figure out a way to do that.

Does anyone have a clue how this is accomplished? I need the resulting
array to be truncated to an array of bytes.

Thanks!

--Kamilche
 
C

Christopher T King

I have a need to multiply all the bytes in a Numeric array, by a
float, such as .9, .8, etc. I can't figure out a way to do that.

By "all the bytes in a Numeric array", I'm assuming you mean you have an
Int8 or UInt8 array. Correct me if I'm wrong.
Does anyone have a clue how this is accomplished? I need the resulting
array to be truncated to an array of bytes.

This should work, assuming my above assumption is correct:

byte_array = array([1,2,3,4,5,6],Int8)
byte_array = (byte_array*.5).astype(Int8)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
SterlingLa
Top