Truncated match.
PICList
Thread
'Doing percentage or ratioThanks'
1999\09\29@120253
by
Quentin
Mike, you are a star!
The 8x8/256 is exactly what I need.
Thanks
Quentin
1999\09\30@114558
by
Harold M Hallikainen
'Doing percentage or ratioThanks'
1999\10\01@024153
by
Michael RigbyJones
> On Wed, 29 Sep 1999 18:02:33 +0200 Quentin <qscKILLspamICON.CO.ZA> writes:
> >Mike, you are a star!
> >The 8x8/256 is exactly what I need.
> >
> >Thanks
> >Quentin
>
> As I mentioned before, I believe it should be 8x8/255 , not 256.
> Try 0xff*0xff/0x100 or 0xff*0xff/0xff
>
> Harold
>
Harold is indeed correct, sorry about that. Dividing by 255 is, however,
far more tricky than 256. If you can live with a maximum error of 1 bit
occaisionally then dividing by 256 may still be a viable option.
Regards
Mike RigbyJones
1999\10\01@130113
by
Harold M Hallikainen

On Fri, 1 Oct 1999 07:41:24 +0100 Michael RigbyJones
<.....mrjonesKILLspam.....NORTELNETWORKS.COM> writes:
>> On Wed, 29 Sep 1999 18:02:33 +0200 Quentin <EraseMEqscspam_OUTTakeThisOuTICON.CO.ZA> writes:
>> >Mike, you are a star!
>> >The 8x8/256 is exactly what I need.
>> >
>> >Thanks
>> >Quentin
>>
>> As I mentioned before, I believe it should be 8x8/255 , not
>256.
>> Try 0xff*0xff/0x100 or 0xff*0xff/0xff
>>
>> Harold
>>
>Harold is indeed correct, sorry about that. Dividing by 255 is,
>however,
>far more tricky than 256. If you can live with a maximum error of 1
>bit
>occaisionally then dividing by 256 may still be a viable option.
>
What I did in this situation was to divide by 256 (throw away the
lower 8 bits) AND, if the MSB of the second operand was set, I
incremented the result. This seemed to work pretty well. An obvious
error of one bit appears at the low end (using 0x00 and 0xff results in
0x01)... Maybe I'll mess with it a bit more... Anyone see a quick and
dirty way to divide a 16 bit number by 255?
Harold
Harold Hallikainen
haroldspam_OUThallikainen.com
Hallikainen & Friends, Inc.
See the FCC Rules at http://hallikainen.com/FccRules and comments filed
in LPFM proceeding at http://hallikainen.com/lpfm
___________________________________________________________________
Get the Internet just the way you want it.
Free software, free email, and free Internet access for a month!
Try Juno Web: dl.http://www.juno.com/dynoget/tagj.
1999\10\01@135927
by
Scott Dattalo

On Fri, 1 Oct 1999, Harold M Hallikainen wrote:
>
> What I did in this situation was to divide by 256 (throw away the
> lower 8 bits) AND, if the MSB of the second operand was set, I
> incremented the result. This seemed to work pretty well. An obvious
> error of one bit appears at the low end (using 0x00 and 0xff results in
> 0x01)... Maybe I'll mess with it a bit more... Anyone see a quick and
> dirty way to divide a 16 bit number by 255?
Yeah, do the 8X8 multiplication. Add the upper byte to the lower byte and
then throw away the lower byte. If you want to round the result up, then
add 0x80 to the lower byte befor throwing it away:
A, B, Yh:Yl
Want A*B/255:
Yh:Yl = A*B
Yh:Yl = Yh:Yl + Yh + 0x80
Yh contains the result.
Maybe my post on this subject the last time didn't make it (I did get a
bounce notification from it). I hate to repeat it, but here's the
essential part:
C = A*B/255
There is another trick that you can attempt. Recall the power series for
division:
N N / / e \ / e \2 / e \3 \
 =  *  1   +    + ... 
v + e v \ \ v / \ v / \ v / /
In Harold's equation, N=A*B, v+e = 255. If you let v=256 and e=1 then the
series simplifies to:
A*B A*B / / 1 \ / 1 \2 / 1 \3 \
 =  *  1 +  +  +  + ... 
256  1 256 \ \256/ \256/ \256/ /
Or just keeping the first two terms:
A*B A*B / 1 \
 ~=  *  1 +  
255 256 \ 256 /
More... (looser matching)
 Last day of these posts
 In 1999
, 2000 only
 Today
 New search...