tag:blogger.com,1999:blog-6010073210891297879.post4832686357404830465..comments2023-09-03T03:30:40.979-07:00Comments on C and C++ Programs: Non - Restoring DivisionLionelhttp://www.blogger.com/profile/11329883633967646018noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-6010073210891297879.post-90756291175828171582010-09-01T06:35:38.466-07:002010-09-01T06:35:38.466-07:00Program for Implementation of Non-Restoring dision...Program for Implementation of Non-Restoring dision<br /><br />http://mumunicomenggprog.blogspot.com/p/programs-for-coa.htmlmumunicomengghttps://www.blogger.com/profile/06239617447790465618noreply@blogger.comtag:blogger.com,1999:blog-6010073210891297879.post-14773728278789757372009-10-23T22:12:35.480-07:002009-10-23T22:12:35.480-07:00It is illustrative, if hopelessly inefficient. hit...It is illustrative, if hopelessly inefficient. hits the division unit an awful lot for code purporting to show how a division is done. (between 21 and 25 times!)<br /><br />Might make more sense to store the numbers in just one int rather than arrays of them. <br />Probably done to avoid the issues of selecting out individual bits with C - something it's not good at, it's "hands" can only grip numbers at least a byte or larger. It works, but it isn't all that clear.<br /><br />Eg, complement is done with a tricky (efficient, which is counter to the purpose) sequential algorithm, when the standard "invert, then add one" would have been clearer. <br />Also, keeps using, "add one, then get the remainder of a division by 2" to invert bits.<br />something like b2c[i]=b[i]?0:1; is clearer, assuming you do know C. <br /><br />Adding each bit also uses _2_ division operations. <br /><br />Also, the code is very poorly commented.<br /><br />Just implementing a non-restoring division on int's or char's using perhaps a union to combine two char's into a short for the left shift, then just adding or subtracting and looping to get the result, as chars would have been shorter and much more readable.Unknownhttps://www.blogger.com/profile/03281133132314298652noreply@blogger.comtag:blogger.com,1999:blog-6010073210891297879.post-3327905698614429062009-08-24T11:31:34.755-07:002009-08-24T11:31:34.755-07:00Terrible code at conveying what is going on, it ma...Terrible code at conveying what is going on, it may work but I have to wonder why.<br />In the world of work this sort of programming just gets binned.Anonymousnoreply@blogger.com