[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Function BYTSCL



Steffen Kernchen wrote:
.. 
> > You are going to have to give us a clue why you
> > should NOT use BYSCL. Is this a religious preference?
> 
> *g*   no, it is a condition for a given exercise.
> itīs for my first program, iīve to write for a new lecture at my
> university.
> so the answer for my question should be quite simple. just 3 or 4 lines...

If you would want to use BYTSCL, but you are not allowed to use
the built-in function, then you can just code up your own scaling.
To scale (= multiply) an array by a certain factor (e.g.,
MyFactor=2):
  MyArray = MyArray * MyFactor
To substract (or add) any offsets:
  MyArray = MyArray - MyOffset
To limit (clip) the array values to a certain range:
  MyArray = MyMinRange < MyArray < MyMaxRange
MIN() or MAX() can be used to find the original range of the
array. You could determine the factor and offset you want to use
from them.

It should be possible to code up something sensible in just a few
lines. Beware of possible overflow, if you are in byte type then
things can easily get >255. So I guess it does make for some good
programming exercise...

cheers,
  Jaco