## Re: Arbitrary precision modulo operation

From: "Dann Corbit" "Dann Corbit" ,"Bruno Wolff III" , "Tom Lane" "Paul Tillotson" , Re: Arbitrary precision modulo operation 2004-04-28 22:06:25 D90A5A6C612A39408103E6ECDD77B8299CAA3E@voyager.corporate.connx.com (view raw, whole thread or download thread mbox) 2004-04-28 22:06:25 from "Dann Corbit"  2004-04-29 02:26:38 from Alvaro Herrera pgsql-general
```/*
** Hopefully, I am not annoying anyone with all of this.
** This is a brief demonstration of how Newton's division algorithm
works:
*/
#include <stdio.h>
double          divide(double x, double y)
{
unsigned __int64 est;
double          y1 = 1.0 / y;
double          y2;
puts("\nForming reciprocal:");
est = y1 * 10000;
y1 = est / 10000.0;         /* make an estimate good to 4 decimal
places... */
printf("x=%.7f, y=%.7f, y1=%.7f\n", x, y, y1);
y1 *= (2 - y * y1); /* should be 8 places */
printf("x=%.14f, y=%.14f, y1=%.14f\n", x, y, y1);
y1 *= (2 - y * y1); /* In theory ~16 digits */
printf("x=%.20f, y=%.20f, y1=%.20f\n", x, y, y1);
y1 *= (2 - y * y1); /* One more is really needed here... */
printf("x=%.20f, y=%.20f, y1=%.20f\n", x, y, y1);
puts("\ndividing:");
printf("result of division is:%f\n", x * y1);
return 0;
}

int             main(void)
{
divide(1.0, 2.0);
divide(1.0, 17.0);
divide(3.0, 19.0);
divide(19.0, 3.0);
return 0;
}

```

### pgsql-general by date

 Next: From: Paul Tillotson Date: 2004-04-28 23:13:16 Subject: Re: Postgre and Web Request Previous: From: Chris Browne Date: 2004-04-28 21:58:24 Subject: Re: Postgre and Web Request

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group