www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/06/26/04:53:29

Xref: news2.mv.net comp.os.msdos.djgpp:5389
From: Paul Shirley <Paul AT chocolat DOT foobar DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Fixed point math
Date: Tue, 25 Jun 1996 22:19:03 +0100
Organization: DrinkSoft
Lines: 22
Distribution: world
Message-ID: <PowcfbAHfF0xEwuY@chocolat.foobar.co.uk>
References: <Pine DOT GSO DOT 3 DOT 94 DOT 960625013434 DOT 2111A-100000 AT zippy>
<31d026a2 DOT 3304948 AT news DOT mcs DOT net>
NNTP-Posting-Host: chocolat.foobar.co.uk
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

In article <31d026a2 DOT 3304948 AT news DOT mcs DOT net>, Peter Johnson
<locke AT mcs DOT net> writes
>>I am curious.  Is there any reason long long ints are not used for fixed
>>point math?  It would provide 64 bits of precision..  Making a 32.32
>>possible...
>>
>Because when you multiply, you would need a long long long int or
>something 128 bits long.. 16.16 uses long long ints for multiplication
>and division.

AFAIK C will truncate a result it can't easily widen. Widening a long
long is not trivial so don't expect it to happen.
The results of integer arithmetic are defined to be the same width as
the widest source operand.  In general C compilers will widen to the
size of an int (which is usually the most convenient size to use) unless
you force it to do otherwise.

The annoying thing is even though I know a P5 can generate 64 bit
intermediates for *,/ convincing a C compiler it can is hard.

-- 
Paul Shirley

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019