From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,9ce095aba33fe8d0 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!newsfeed-0.progon.net!progon.net!news-zh.switch.ch!switch.ch!cernne03.cern.ch!cern.ch!news From: Maciej Sobczak Newsgroups: comp.lang.ada Subject: Re: Negative float problem Date: Thu, 03 Nov 2005 16:02:05 +0100 Organization: CERN - European Laboratory for Particle Physics Message-ID: References: <1130351574.313991.229420@g14g2000cwa.googlegroups.com> <10mspnley7gzu$.1swtj67sv0ldr$.dlg@40tude.net> <38tcpxwxfigo$.18ysjyp9ml92c$.dlg@40tude.net> <2ybc7t4au7g$.166dxwfrds1so$.dlg@40tude.net> <18nrnlg9zzl5a.k8rl3ajwauqi.dlg@40tude.net> NNTP-Posting-Host: abpc10883.cern.ch Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sunnews.cern.ch 1131030125 7021 (None) 137.138.37.241 X-Complaints-To: news@sunnews.cern.ch User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20050922 Red Hat/1.7.12-1.1.3.2.SL3 X-Accept-Language: en-us, en In-Reply-To: Xref: g2news1.google.com comp.lang.ada:6145 Date: 2005-11-03T16:02:05+01:00 List-Id: Jean-Pierre Rosen wrote: > For example, try to find what "%" does in C/C++ (with at least one > negative operand, of course)... For fundamental types, this always holds (except when b is 0): a == (a / b) * b + a % b If any of a or b is negative, then the sign of a % b is implementation-defined. (for user-defined types - like MySuperSafeIntegerWithLotsOfChecks - it's of course whatever you invent it to be) I have to admit that I was never concerned with this rule, I just don't divide modulo negative numbers - this kind of operation simply has no meaning in any of the domains where I used C/C++. -- Maciej Sobczak : http://www.msobczak.com/ Programming : http://www.msobczak.com/prog/