[CLN-list] More bugs.
Isidro Cachadiña Gutiérrez
icacha at unex.es
Tue Dec 14 09:20:25 CET 2004
El Martes, 14 de Diciembre de 2004 00:21, Richard B. Kreckel escribió:
> >
> > b = a*cl_float(2.72,precission)/c*cl_float(7.28,precision);
>
> Unless that statement is inside a loop anyway (in which case the constant
> factor ought to be hoisted out) I would write that such things rather as
> b = cl_float( 2.72*7.28, precision ) * a / c;
mmm .... I'm not sure because of perhaps 2.72*7.28 is converted to a float
and then ... let see:
#include <iostream>
#include <cln/float.h>
#include <cln/float_io.h>
using namespace cln;
int main(int argc, char **argv)
{
cl_F a,b;
a="1.0_100";
a=cl_float(9.0/7.0,a)*a;
std::cout << a << std::endl;
b="1.0_100";
b=cl_float(9,b)/cl_float(7,b)*b;
std::cout << b << std::endl;
}
--- The output ---
1.2857142857142858094476878250134177505970001220703125L0
1.2857142857142857142857142857142857142857142857142857142857142857142857142857142857142857142857142857142857142857143L0
Better the second, no?
Nos vemos.
--
***************************************************************************
* Dr. Isidro Cachadiña Gutiérrez *
* Departamento de Física *
* Facultad de Ciencias *
* Universidad de Extremadura *
* 06071 Badajoz ( SPAIN ) *
* email: icacha at 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 *
***************************************************************************
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.cebix.net/pipermail/cln-list/attachments/20041214/a84a1152/attachment.pgp
More information about the CLN-list
mailing list