Re: [pure-lang-users] C float
Status: Beta
Brought to you by:
agraef
From: Eddie R. <er...@bm...> - 2008-08-13 16:09:01
|
On Wed, 2008-08-13 at 11:16 -0400, John Cowan wrote: > Eddie Rucker scripsit: > > > Thanks. What about const and unsigned parameters? > > Casting away const is always safe: const essentially documents how the callee > uses the argument or its referent. Ok. I understand this one. > Unsigned does need explicit support to consistently get the right results: > in particular, a too-big unsigned value should become a bignum. Hmm. I didn't even think about big numbers. I was worried about the following scenario: Some C library called f2.so defined by: unsigned int foo(unsigned int a) { return a + 1; } Then from Pure: > using "lib:/t2.so"; > extern int foo(int); > let a = 2147483646; > foo (a div -1); -2147483645 Now, the following C program gives different results: #include <stdio.h> unsigned int foo(unsigned int a) { return a + 1; } int main() { unsigned int a = 2147483646; printf("%d\n", foo(a/-1)); return 0; } Results: :~$ ./a.out 1 e.r. |