Numeric - Multiply a byte array by a float.

Christopher T King squirrel at WPI.EDU
Wed Jul 14 09:57:58 EDT 2004


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)




More information about the Python-list mailing list