470,849 Members | 1,371 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,849 developers. It's quick & easy.

Numeric - Multiply a byte array by a float.

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
Jul 18 '05 #1
1 3099
On 13 Jul 2004, Kamilche wrote:
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)

Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Phil | last post: by
1 post views Thread by Philippe Grosse | last post: by
235 posts views Thread by napi | last post: by
8 posts views Thread by Kenny ODell | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.