mirror of
https://github.com/adtools/clib2.git
synced 2025-12-08 14:59:05 +00:00
- Added "factorial" test program for "%g" testing.
git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15077 87f5fb63-7c3d-0410-a384-fd976d0f7a62
This commit is contained in:
25
test_programs/factorial.c
Normal file
25
test_programs/factorial.c
Normal file
@ -0,0 +1,25 @@
|
||||
#include <stdio.h>
|
||||
|
||||
/*
|
||||
gcc -std=c99 -mcrt=clib2 -o factorial factorial.c -lm
|
||||
output is:
|
||||
16! = 20922789888 <- Wrong
|
||||
|
||||
gcc -std=c99 -mcrt=newlib -o factorial factorial.c
|
||||
output is:
|
||||
16! = 20922789888000 <- Correct
|
||||
*/
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
double result = 1.0;
|
||||
int i;
|
||||
|
||||
for ( i = 2; i < 17; ++i )
|
||||
result = result * i;
|
||||
|
||||
printf("16! = %.14g\n", result);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user