Hi Andy, On Thu, Oct 4, 2012 at 4:13 PM, andy pugh <[email protected]> wrote: > On 4 October 2012 01:37, Dave Hylands <[email protected]> wrote: > >> There is do_div (for all architectures) and div_u64_rem (for x86) in >> <asm/div64.h> > > do_div appears to be almost perfect. But I really don't understand it. > > I can pull out the digits really easily with > > for (i = c ; i > 0 ; i--){ > out[i] = digits[do_div(tmp, 10)]; > } > (digits is an array of numerals and abcdef) > > do_div returns the remainder, and divides the first argument by the > second. _in_place_. > It's the in-place bit I don't understand. It isn't passed by > reference, it isn't a pointer, it is a normal u64 integer. > (I tried using a pointer, and it doesn't work) > > http://codepad.org/UdqruNIt shows an example. > > What am I missing? I read of "understanding the side effects" on the > web. I don't even understand the intended effects.
Kent mentioned this, but I thought I'd put it a bit more explicitly. It works because do_div is a macro and not a function. -- Dave Hylands Shuswap, BC, Canada http://www.davehylands.com ------------------------------------------------------------------------------ Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev _______________________________________________ Emc-developers mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/emc-developers
