Significant Figures and Chemistry
does anyone know if there are any built in functions in C++ that make using these much easier? also, does anyone know if there are some built in chemistry constants or functions?
ostreams like cout have a number of member functions that can format output for you. Some are called manipulators. Others are called flags. One of the manipulators is setprecision(). It indicates the number of significant digits after the decimal point the stream will use with floating point numbers. One of the flags is scientific. It handles floating point numbers in scientific notation. You can set flags when opening streams or with use of the setf() function. Here's an example that I think should work;
double example = 623456789;
cout << setprecision(2) << setf(ios::scientific) << example << endl;
should show 6.23e8 on the screen--if I did my math and my C++ right.
To my knowledge there are no standard C++ libraries that deal with chemistry like there is one for math. However, I strongly suspect you can find third party libraries with much of what you want, and if you can't do that you can write your own! (eventually)
I know about those formating functions, but I was hoping for something that I could use for basic math and find the significant figures automatically. like if
this stored 7.6 as c instead of 7.595
I am not aware of such a function. Sorry.