EDIT: this is similar
to
https://groups.google.com/forum/#!searchin/julia-users/promotion/julia-users/UivFNQUaIHI/kw5K-6dOsWEJ
in spirit,
though mine is a very typical use case when dealing with images, beyond the
32/64-bit discussion.
Note that I can also do
b = uint8( A / 2 )
but that would allocate much more memory (4x) than necessary.
El viernes, 4 de abril de 2014 11:09:24 UTC+2, Carlos Becker escribió:
>
> I've seen previous posts in this list about this, but either I missed some
> of them or this particular issue is not addressed. I apologize if it is the
> former.
>
> I have a Uint8 array and I want to divide (still in Uint8) by 2. This is
> very handy when dealing with large images: no need to use more memory than
> needed.
> So, for example:
>
> A = rand(Uint8, (100,100)); # simulated image
>
> b = A / uint8(2)
>
> typeof( b ) # ==> returns Array{Float32,2}
>
>
> I understand why one may want that, but is there a way to override it and
> do the plain, element-wise uint8-by-uint8 division?
> (ie ignore promotion rules)
>
> Thanks.
>