| | |
approximate the value of PI
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
Declaring variables inside for loop initialization sections is indeed C99-only. I wouldn't do it if I were you.
double just has more precision (usually). Oftentimes, a float is 4 bytes and a double is 8. There used to be a speed penalty for using floating-point numbers, which is why float exists, but there's not really any reason not to use double any more.
[edit] *hides even further away* [/edit]
•
•
•
•
Btw, what are the differences between float and double?
[edit]
C Syntax (Toggle Plain Text)
for (i = 0, sum = 0.0; i < n; ++i, sum += ((i % 2) * 2 - 1) * (1.0 / (1 + i * 2)));
Last edited by dwks; Sep 4th, 2008 at 5:54 pm.
dwk
Seek and ye shall find.
"Only those who will risk going too far can possibly find out how far one can go."
-- TS Eliot.
"I have not failed. I've just found 10,000 ways that won't work."
-- Thomas Alva Edison
"The only real mistake is the one from which we learn nothing."
-- John Powell
Seek and ye shall find.
"Only those who will risk going too far can possibly find out how far one can go."
-- TS Eliot.
"I have not failed. I've just found 10,000 ways that won't work."
-- Thomas Alva Edison
"The only real mistake is the one from which we learn nothing."
-- John Powell
>*hides even further away*
There's nothing hidden there. Obfuscated, perhaps. Quite often, hard to read code, it is associated with cleverness, when the opposite it is true.
An abstraction layer is the only place where "hiding" some "goring details" of a program should be used. And interesting enough, it is for the sake of simplicity.
There's nothing hidden there. Obfuscated, perhaps. Quite often, hard to read code, it is associated with cleverness, when the opposite it is true.
An abstraction layer is the only place where "hiding" some "goring details" of a program should be used. And interesting enough, it is for the sake of simplicity.
![]() |
Similar Threads
- Approximate Value of pi, incorrect results (C++)
- "page cannot be displayed" only w/ router (Networking Hardware Configuration)
- Error creating new ASP.Net project (ASP.NET)
- IE6 has been constantly hijacked by .... (Viruses, Spyware and other Nasties)
- Pi Approximation (C++)
Other Threads in the C Forum
- Previous Thread: Having problems in using linked lists
- Next Thread: Why address Gap in Char?
| Thread Tools | Search this Thread |
#include * append array arrays asterisks bash binarysearch calculate changingto char character cm copyimagefile creafecopyofanytypeoffileinc createprocess() database dynamic execv feet fgets file floatingpointvalidation fork forloop framework function getlogicaldrivestrin givemetehcodez global grade gtkwinlinux hacking histogram ide include incrementoperators input intmain() iso kernel keyboard kilometer km license linked linkedlist linux list lists locate logical_drives looping loopinsideloop. lowest matrix meter microsoft mqqueue number oddnumber odf opensource openwebfoundation overwrite owf pdf performance pointer posix probleminc process program programming radix recursion recv recvblocked research reversing scripting segmentationfault sequential single socket socketprogramming standard strchr string systemcall testing threads turboc unix urboc user variable wab whythiscodecausesegmentationfault windowsapi






