El Martes, 14 de Diciembre de 2004 08:47, Isidro Cachadiña Gutiérrez escribió:
Well. Is this a bug and is it well reported? .. --------------------------------------------------------------------------- --------------- #include <iostream> #include <cln/float.h> #include <cln/float_io.h>
using namespace cln; int main(int argc, char **argv) {
// Wrong result?
float_format_t prec; prec=float_format(100);
cl_F a,b,c; b=cl_float(1.0e-10,prec); a=cl_float(1.0,prec); c=a+b;
std::cerr << "Incorrect: " << std::endl;
std::cerr << "c=" << c << std::endl; c=c-a; std::cerr << "c=" << c << std::endl;
// Right result
std::cerr << "Correct:" << std::endl;
a="1.0_100"; b="1.0e-10_100"; c=a+b;
std::cerr << "c=" << c << std::endl; c=c-a; std::cerr << "c=" << c << std::endl;
} --------------------------------------------------------------------------- ----------- The output in my computer. =================================================== Incorrect: c=1.00000000010000000000000000364321973154977415791655470655996396089904010 295867919921875L0 c=1.00000000000000003643219731549774157916554706559963960899040102958679199 21875L-10 Correct: c=1.0000000001L0 c=9.99999999999999999999999999999999999999999999999999999999999999999999999 9999999999999999999999999999999997972106604L-11 ===================================================
A ver si esta vez...
Well. I answer myself. This is a feature since the conversion is done at running time, then 1e-10 is stored as 1.000......3643e-10 and the cl_float anly can add zeroes. But this functionality is good then perhaps a mix between a="number_<precision> " can be done : for example float_format_t prec; prec=float_format(100); a=cl_float("1.0e-10",prec); a function cl_F cl_float(char *,float_format_t) I haven't the documentation here now and I don't remenber if this function is implemented yet but I'll be happy if this functions is somewhere. Thanks. -- *************************************************************************** * Dr. Isidro Cachadiña Gutiérrez * * Departamento de Física * * Facultad de Ciencias * * Universidad de Extremadura * * 06071 Badajoz ( SPAIN ) * * email: icacha@unex.es * * Teléfono: +34 924 289 300 Ext. 6826 Fax: +34 924 289 651 * *************************************************************************** * Usuario Linux: 8569 * * Para clave pública GnuPG: http://onsager.unex.es/firma.pub.asc * ***************************************************************************