MESSAGE
DATE | 2010-02-02 |
FROM | Ruben Safir
|
SUBJECT | Subject: [NYLXS - HANGOUT] C++ Workshop I datatypes cont..
|
Hello,
first, thank you for starting this. I know it is hard work to put this together, and it seems unfair to chritisize this when I have not yet contributed anything. I will try to be constructive: When talking about data types I think it is important for the sake of better coding to use C++ constructs rather than pulling these old c limits.h.
C++ data types, unlike java, are implementation dependent. To deal with this the C++ standard provides for the basic data type (short, int, float, double, char, unsigned, long) a standardized interface.
numeric_limits is the C++ way to deal with the implementation details of basic types.
here a small example how to use numeric_limits: = limits_int.cpp =============================== #include #include
using namespace std;
int main () { cout << "Minimum value for int: " << numeric_limits::min() < cout << "Maximum value for int: " << numeric_limits::max() < return 0; } ================================================
the functions min and max are defined statically so you can call the directly. The class numeric_limits provides you wit a set of very useful information: min() max() digits digits10 is_signed is_integer is_exact radix epsilon() round_error() min_exponent min_exponent10 max_exponent max_exponent10 has_infinity ... to name the more important ones.
Henning -- Henning Follmann | hfollmann-at-itcfollmann.com it consultant | www.itcfollmann.com
_____________________________________________________________________________ Hire expert Linux talent by posting jobs here :: http://jobs.nylug.org The nylug-talk mailing list is at nylug-talk-at-nylug.org The list archive is at http://nylug.org/pipermail/nylug-talk To subscribe or unsubscribe: http://nylug.org/mailman/listinfo/nylug-talk
----- End forwarded message -----
-- http://www.mrbrklyn.com - Interesting Stuff http://www.nylxs.com - Leadership Development in Free Software
So many immigrant groups have swept through our town that Brooklyn, like Atlantis, reaches mythological proportions in the mind of the world - RI Safir 1998
http://fairuse.nylxs.com DRM is THEFT - We are the STAKEHOLDERS - RI Safir 2002
"Yeah - I write Free Software...so SUE ME"
"The tremendous problem we face is that we are becoming sharecroppers to our own cultural heritage -- we need the ability to participate in our own society."
"> I'm an engineer. I choose the best tool for the job, politics be damned.< You must be a stupid engineer then, because politcs and technology have been attached at the hip since the 1st dynasty in Ancient Egypt. I guess you missed that one."
? Copyright for the Digital Millennium
|
|