@Jaspreet: The % operator is implemented using division, which is considered an arithmetic operation, not a bitwise operation. On primitive chips, as may be used in specialized hardware, division may not be implemented, in which case a non-division based algorithm may be desired. The question may be based on that idea, or just on how to do it faster than using division, which typically is a very slow instruction (compared to other machine instructions). Dave
On Thursday, October 11, 2012 4:14:17 AM UTC-5, Jaspreet Singh wrote: > Nice solution Dave sir .. but if you know can you please tell us what is > the internal structure of "%" operator .. i mean it has also to be done by > bitwise any way .. so can't we implement that in HHLs. > > Thanks > > On Thu, Oct 11, 2012 at 1:25 AM, Dave <dave_an...@juno.com > <javascript:>>wrote: > >> @Mohit: The decimal representation of a number ends in 5 if its low order >> bit is 1 and it is divisibile by 5. >> >> An algorithm using bitwise operations to check for divisibility by 5 is >> given at >> https://groups.google.com/d/msg/algogeeks/I5HWmwKW_ks/n38FWJSd0l8J. >> >> It probably is not as fast as (n & 1) && (n % 5 == 0), though. >> >> Dave >> >> On Wednesday, October 10, 2012 4:06:28 AM UTC-5, mohit mishra wrote: >> >>> >>> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To view this discussion on the web visit >> https://groups.google.com/d/msg/algogeeks/-/bRupe9F1MUIJ. >> >> To post to this group, send email to algo...@googlegroups.com<javascript:> >> . >> To unsubscribe from this group, send email to >> algogeeks+...@googlegroups.com <javascript:>. >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> > > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/XF05MQd7Ne4J. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.