Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

John Edgar Congote Calle http://jcongote.blogspot.com

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

Calcular el epsilon de la libreria gmp

Este codio calcula el epsilon de la libreria gmp, variando en cada ciclo la presicion del numero.

#include <iostream>
#include <limits.h>
#include <gmpxx.h>

using namespace std;


int main(int argc, char **argv){
	unsigned long int i,j;
//	4294967295

	for (i=1;i<4294967295UL;i*=2){
		j=0;
		mpf_class epsilon(0.5,i);

		while(epsilon+1 != 1){
		//cout.precision(200000);
		//cout<<"Epsilon: "<<epsilon<<endl;
			epsilon /= 2;
			j++;
		};
		cout.precision(20);	
//	cout<<"Precision: "<<ULONG_MAX<<endl;
		cout<<"Epsilon Final: "<<epsilon<<" Numero de ciclos: "<<j<<" Precision: "<<i<<endl;
	}

	return 0;
}
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS