TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: ROBERT DAVIES
from: THOMAS HABETS
date: 1998-01-22 19:01:00
subject: I do not under srand this can anyone enl19:01:3101/22/98

 RD> Does 1.e3 mean one multiplied by a thousand, and 1.e-3 mean
 RD> one multiplied by minus a thousand?
1.e3  = 1 * 10^3    = 1 * 1000
1.e-3 = 1 * 10^-3   = 1 * .001
 RD> cout << 1.23e2           << endl; //  123
1.23 * 10^2 = 1.23 * 100 = 123
 RD> cout << 123.e-2          << endl; //  1.23
123 * 10^-2 = 123 * .01 = 1.23
 RD> cout << 0.123456789 << endl; //  0.1234567
FLoat numbers are limited, use double or long double.
(ok, so they are limited too, but not as much).
cout << (long double)0.123456789 << endl;
 RD> cout << 123456789.   << endl; //  1.234567e+8
It's a float and floats are represented like that.
 RD> cout << 1./2.       << endl; //  0.5
Float/float gives float answer.
 RD> cout << 1./2        << endl; //  0.5
Float/int gives float answer.
 RD> cout << 1 /2.       << endl; //  0.5
Int/float gives float answer.
 RD> cout << 1 /2        << endl; //  0
int/int gives int answer.
 RD> As you can see it is a very basic program
ARGH! He said the B-word, kill him NOW!
:-)
---
---------------
* Origin: Recursive, adj.; see Recursive (2:201/293.22)

SOURCE: echomail via exec-pc

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™.