Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site aesat.UUCP Path: utzoo!aesat!bmw From: bmw@aesat.UUCP (Bruce Walker) Newsgroups: net.math,net.arch Subject: Re: Integer division Message-ID: <557@aesat.UUCP> Date: Tue, 11-Feb-86 15:13:41 EST Article-I.D.: aesat.557 Posted: Tue Feb 11 15:13:41 1986 Date-Received: Tue, 11-Feb-86 15:19:02 EST Organization: AES Data Inc., Mississauga Ont., Canada Lines: 32 | Is there someone out there who *wants* a/b to round towards 0 (for reasons | that say that is the desired result)? I asked that before and have not seen | any affirmatives. | | ucbvax!brahms!weemba Matthew P Wiener/UCB Math Dept/Berkeley CA 94720 Yes, *I* want a/b to round toward 0, and for a good (although selfish) reason. (I also want divide to produce *both* result *and* remainder which answers a question posed by someone else on just that point.) When I write the firmware for the disk controller boards I design, I want that code to run as fast as possible (so do you, if your machine uses my board!). When a logical block address is handed to me, I do an integer divide by the number of sectors per track which produces both a quotient and remainder. The quotient will represent the track I should seek, and the remainder represents the sector I should read. No extra work is done, and all the micros I would normally use for this kind of purpose do what I expect. The above algorithm is simplified of course, one would normally have to consider bad-block management etc., but the principle remains intact. So, if as a result of this discussion, every uP manufacturer ups and "fixes" his microcode, don't come crying to me that all your disk reads take 20 more microseconds than they used to. Bruce Walker {allegra,ihnp4,linus,decvax}!utzoo!aesat!bmw "I'd feel a lot worse if I wasn't so heavily sedated." -- Spinal Tap