Path: chuka.playstation.co.uk!news From: "Steve Dunn" Newsgroups: scea.yaroze.programming.gnu_compiler Subject: Re: long long ints for improved accuracy Date: Mon, 16 Feb 1998 19:00:49 -0000 Organization: PlayStation Net Yaroze (SCEE) Lines: 70 Message-ID: <6ca2bs$beo27@chuka.playstation.co.uk> References: <673ein$9k37@chuka.playstation.co.uk> NNTP-Posting-Host: usera830.uk.uudial.com X-Newsreader: Microsoft Outlook Express 4.72.2106.4 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.2106.4 I've had a similar problem. It's under the tree 'C++ Include paths' (near the bottom(at the moment)). If you have any luck resolving this, I'd appreciate a nudge. Cheers John Steve john.rees@dial.pipex.com wrote in message <673ein$9k37@chuka.playstation.co.uk>... >I am trying to use long long ints to hold temporary values during >fixed point calculations, but if I use divide and modulus operations >then the linker complains that certain functions are not found. > >gcc basic.o -Xlinker -Map -Xlinker mapfile -Xlinker -Ttext -Xlinker >80100000 -o basic >basic.o: In function `main': >basic.c:11: undefined reference to `__divdi3' >basic.c:11: relocation truncated to fit: JMPADDR __divdi3 >basic.c:12: undefined reference to `__moddi3' >basic.c:12: relocation truncated to fit: JMPADDR __moddi3 >make.exe: *** [basic] Error 1 > >It is strange that add, subtract and multiply seem to work, but divide >and modulus are not provided. Even if these would be slow to execute >on a 32 bit machine, it would be VERY useful. > > >#include > >#define printll(v) printf(#v "=%08x %08x\n", *(((int*)&v)+1), >*(int*)&v ) > >int main(void) >{ > long long x = 0x123456; > long long y = 0x100000; > long long prod = (x-y)*y; > long long quot = x/y; > long long rem = x%y; > > printll(x); > printll(y); > printll(prod); > printll(quot); > printll(rem); > > return 0; >} > >With the "quot" and "rem" lines commented out, the output is: > >x=00000000 00123456 >y=00000000 00100000 >prod=00000023 45600000 > >Thanks to Alex Amsel for a throwaway remark in the More Pointless >Optimisation Tricks thread that made me aware of long longs. >After struggling with fixed point numbers for far too many hours I >really hope someone can help with this. > >john > >