Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. COChris Torek! That's _you_! Thank you so much for your answer! Really I couldn't hope for a better source :) (As for indentation, maybe the original was closer to this [div.c](http://svnweb.freebsd.org/base/head/lib/libc/stdlib/div.c?view=co)?) (Also, in the meantime I have been doing more web-searching, and found [another "fix"](http://www.beedub.com/Sprite093/src/lib/c/stdlib/div.c) (the XOR seems legit but the adjustment wrong), and especially **[a code from 1987](https://raw.github.com/7shi/minix-tools/master/lib/c/ansi/div.c)** (!) which seems to handle both 42/-5 _and_ -42/5 correctly!)
      singulars
    2. COYes, that's basically the original (K&R-ish, "high Bosticity" indentation :-) ... what eventually became style(9) in FreeBSD). I never saw the Sprite version, nor the Vrije Universiteit one, before. The xor seems risky with plain (signed) `int`. The `static` method is valid, but in all cases the need for a run-time test just seems messy, somehow. Even if we can't count on C99 it would be nice to have a compiler-specific #define describing integer divide behavior, since so many machines "behave the way C99 wants" in the first place.
      singulars
    3. COIndeed. **I have filed a [glibc bug report](http://sourceware.org/bugzilla/show_bug.cgi?id=15799).** (By the way, the Vrije Universiteit one was close, but e.g. on a machine that always floors the quotient towards -infinity, `div(-10, 5)`, which yields `{-2, 0}`, will be incorrectly "corrected" to `{-1, -5}`...)
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload