| Forum |
|
|||||||
| Programming The destination for developers - C, C++, Java, Python and the lot |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|
#1 (permalink) |
|
Cool and Calm
Join Date: Jul 2006
Location: Bangalore
Posts: 395
|
Anyway, this is my doubt: i couldn't find this in Google....... ---> if we declare a float, like: float a=2.7; it gets stored in the memory as 2.700000 with specifically 6 digits only, after the decimal point. Why? (may be related to its format)
__________________
When Roger's at play, opponents pray..!!!!! |
|
|
| Advertisements. Register and be a member of the community to get rid of them. | |
|
Advertisement
|
|
|
|
#2 (permalink) | |
|
Wise Old Owl
Join Date: Nov 2006
Location: Pune, Maharashtra, India
Posts: 1,728
|
Quote:
__________________
KDE on ArchLinux PHP, MySQL, PostgreSQL, Linux, Apache; Message me to hire (freelancing only) Explore Technology @ http://www.itech7.com Cheap and Reliable VPS Hosting @ http://j.mp/arHk5e |
|
|
|
|
|
#3 (permalink) |
|
Security Exp
Join Date: Apr 2006
Posts: 733
|
Yes by default it is upto 6 point decimal...
But if you want it to 3 point decimal than use %.3f in the print statement to get result in upto 3 place of decimal e.g. printf("salary is %.3f\n", salary ); For in depth Knowledge read Dennis Ritche
__________________
We Love Once, And When We do We do it Well |
|
|
|
|
#4 (permalink) | |
|
String Phreak
Join Date: Mar 2005
Location: In ur Evil Mind!
Posts: 2,453
|
U can set any precision u want! Check my code
Quote:
__________________
Bad Bad server.....No candy for u! |
|
|
|
|
|
#5 (permalink) |
|
Cool and Calm
Join Date: Jul 2006
Location: Bangalore
Posts: 395
|
thanks for your replies......
but still not satisfied somewhat... i think it goes with the storage space reserved........like float requires 4 bytes in a standard turbo c compiler.....and we need to do some 'masala munch' with these 4 bytes.....
__________________
When Roger's at play, opponents pray..!!!!! Last edited by abhi_10_20; 16-03-2007 at 09:39 PM. |
|
|
|
|
#6 (permalink) | |
|
Wise Old Owl
Join Date: Nov 2006
Location: Pune, Maharashtra, India
Posts: 1,728
|
Quote:
__________________
KDE on ArchLinux PHP, MySQL, PostgreSQL, Linux, Apache; Message me to hire (freelancing only) Explore Technology @ http://www.itech7.com Cheap and Reliable VPS Hosting @ http://j.mp/arHk5e |
|
|
|
|
|
#8 (permalink) | |
|
Wise Old Owl
Join Date: Nov 2006
Location: Pune, Maharashtra, India
Posts: 1,728
|
Quote:
__________________
KDE on ArchLinux PHP, MySQL, PostgreSQL, Linux, Apache; Message me to hire (freelancing only) Explore Technology @ http://www.itech7.com Cheap and Reliable VPS Hosting @ http://j.mp/arHk5e |
|
|
|
|
|
#11 (permalink) |
|
Wise Old Owl
Join Date: Nov 2006
Location: Pune, Maharashtra, India
Posts: 1,728
|
If you want a detailed manual on programming in C, see snip
i have uploaded it. __________ After giving the captcha code, wait 30 secs. goto the bottom. when the downlaod now button gets activated, click it to download. Don't use any d/w manager. __________ Was it useful?
__________________
KDE on ArchLinux PHP, MySQL, PostgreSQL, Linux, Apache; Message me to hire (freelancing only) Explore Technology @ http://www.itech7.com Cheap and Reliable VPS Hosting @ http://j.mp/arHk5e Last edited by mehulved; 20-03-2007 at 11:22 PM. Reason: Automerged Doublepost |
|
|
|
|
#13 (permalink) | |
|
Wise Old Owl
Join Date: Nov 2006
Location: Pune, Maharashtra, India
Posts: 1,728
|
Quote:
__________________
KDE on ArchLinux PHP, MySQL, PostgreSQL, Linux, Apache; Message me to hire (freelancing only) Explore Technology @ http://www.itech7.com Cheap and Reliable VPS Hosting @ http://j.mp/arHk5e |
|
|
|
|
|
#14 (permalink) | |
|
Security Exp
Join Date: Apr 2006
Posts: 733
|
Quote:
in the pdf mentiontioned page number 22 gives the idea about your problem
__________________
We Love Once, And When We do We do it Well Last edited by mehulved; 20-03-2007 at 11:24 PM. |
|
|
|
|
|
#15 (permalink) | |
|
gEttIn 0uT@@@ BOXX
Join Date: Mar 2007
Location: in the webspace
Posts: 83
|
Quote:
printf("salary is %.3f\n", salary ); being more clear this will print upto 3 places after decimal if u write printf("salary is %.2f\n", salary ); this prints 2 values and so on ..
__________________
Koi CHAKAR NAHI HAI >> SAB JUGAAD HAI |
|
|
|
|
|
#16 (permalink) | |
|
Security Exp
Join Date: Apr 2006
Posts: 733
|
Quote:
__________________
We Love Once, And When We do We do it Well Last edited by mehulved; 20-03-2007 at 11:25 PM. |
|
|
|
|
|
#17 (permalink) | |
|
Wise Old Owl
Join Date: Nov 2006
Location: Pune, Maharashtra, India
Posts: 1,728
|
Quote:
__________________
KDE on ArchLinux PHP, MySQL, PostgreSQL, Linux, Apache; Message me to hire (freelancing only) Explore Technology @ http://www.itech7.com Cheap and Reliable VPS Hosting @ http://j.mp/arHk5e |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|