| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Re: Organizing source code |
From: "Paul Ranson"
I don't think you ever have to write '2.0' unless it's important to know
that this is a floating point type for compile time arithmetic or function
overloading
For instance,
double d1 = 22 / 7 ;
double d2 = 22.0/7 ;
cout << "d1 = " << d1 << ", d2 = "
<< d2 << "\n" ;
produces,
d1 = 3, d2 = 3.14286
whereas,
d1 = 22 ;
d2 = 7 ;
std::cout << "22/7 = " << d1/d2 << "\n" ;
produces,
22/7 = 3.14286
All languages that do integer and floating point arithmetic have to have
conventions for this type of thing.
Paul
"Geo" wrote in message news:4179884a{at}w3.nls.net...
> "John Beckett"
wrote in message
> news:4178e2cc.15036661{at}216.144.1.254...
>
>> C++ uses the C philosophy that if the hardware can do it, then the
>> language should be able to call it. So, since most hardware can handle
>> single-precision and double-precision floating point numbers, the
>> language
>> should handle both.
>
> Ok, that's a logical philosophy.
>
>> If you ever wanted to work with arrays of (say) 100 million floating
>> point
>> numbers, you might be glad you can specify float (4 bytes in VC) rather
>> than double (8 bytes).
>
> Yeah I can see that too, but there is other stuff that bothers me about
> the
> language. For example there are times when you have to say something is
> =2.0
> instead of =2 but when it cout's a double number with no output
> specification the default is to just output 2 not 2.0. It's kinda like the
> machine doesn't have to play by the same rules the programmer has to play
> by..
>
> Geo.
>
>
--- BBBS/NT v4.01 Flag-5
* Origin: Barktopia BBS Site http://HarborWebs.com:8081 (1:379/45)SEEN-BY: 633/267 270 5030/786 @PATH: 379/45 1 396/45 106/2000 633/267 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.