Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | 88888 Dihedral <dihedral88888@googlemail.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! |
| Date | 2011-11-25 17:40 -0800 |
| Organization | http://groups.google.com |
| Message-ID | <14304310.720.1322271627269.JavaMail.geo-discussion-forums@pret21> (permalink) |
| References | <24357587.77.1321816326271.JavaMail.geo-discussion-forums@prnv30> <4ece40e9$0$1385$4fafbaef@reader2.news.tin.it> <459390d2-53c4-49cc-9b97-c25337d9007e@o5g2000yqa.googlegroups.com> |
On Saturday, November 26, 2011 7:31:46 AM UTC+8, Lew Pitcher wrote:
> On Nov 24, 8:08 am, "io_x" <a...@b.c.invalid> wrote:
> > "88888 Dihedral" <dihedr...@googlemail.com> ha scritto nel messaggionews:24357587.77.1321816326271.JavaMail.geo-discussion-forums@prnv30...
> >
> > > PROBLEM 1: COMPUTE THE EULER'S NUMBER UP TO 30 DIGITS AFTER 1.
> > > THE DIGIT REQUIRED SHOULD BE PARAMETER BY THE CALLER!
> >
> > yes but i'm a little ot because it is C++...
>
> So, let's try something /on-topic/, then, shall we?
>
> /*
> ** This program was inspired by the article "The Impossible Dream:
> ** Computing e to 116,000 places with a Personal Computer" by
> ** Stephen Wozniak, published in Byte Magazine Vol 6, Issue 6
> ** (June 1981, pp392).
> **
> ** Essentially, the following program implements a partial expansion
> ** of the equation: e = 1 + (1/1!) + (1/2!) + (1/3!) + ... + (1/n!)
> ** by inverting the equation, such that it reads...
> ** e = (((((...(((((1/n) + 1) / (n-1)) + 1) ... / 3) + 1) / 2) + 1) /
> 1) + 1
> **
> ** I originally wrote this program in Z80 Assembler code, to run under
> ** CP/M (Dec 1986), and subsequently have recoded the program in
> ** 370 Assembler to run under MVS and VSE, and C to run under MSDOS
> ** and Linux
> **
> ** Lew Pitcher, 1999
> */
> #include <stdio.h>
>
> #define I 1 /* number of bytes in integer portion */
> #define X 2078 /* number of bytes in fraction portion */
> #define N 1776 /* number of divide iterations */
> #define P 5000 /* number of multiply iterations */
>
> char e[I+X]; /* holds fixed point binary value of e */
>
> int main(void)
> {
> void divide(char *, unsigned, unsigned),
> multiply(char *, unsigned, unsigned);
>
> unsigned n, /* divisor for calculation loop */
> p; /* precision for print loop */
>
> e[0] = 1; /* start the series at 1.anything */
> for (n = N; n > 0; --n)
> {
> divide(e,n,I+X);
> e[0] += 1;
> }
>
> fputs(" e == ",stdout); fputc(e[0]+'0',stdout); fputc('.',stdout);
> for (p = 0; p < P; ++p)
> {
> e[0] = 0;
> multiply(e,10,I+X);
> fputc(e[0]+'0',stdout);
> if (p%5 == 4)
> if (p%50 == 49)
> fputs("\n\t",stdout);
> else
> fputc(' ',stdout);
> }
> fputc('\n',stdout);
>
> return 0;
> }
>
> void divide(char *dvd, unsigned dvr, unsigned prc)
> {
> char *Wk_q;
> unsigned bit, rmdr;
>
> rmdr = 0;
> for (Wk_q = dvd; Wk_q < dvd+prc; ++Wk_q)
> {
> for(bit = 0; bit < 8; ++bit)
> {
> rmdr *= 2;
> if (*Wk_q & 0200) rmdr += 1;
> *Wk_q <<= 1;
> if (rmdr >= dvr)
> {
> *Wk_q += 1;
> rmdr -= dvr;
> }
> }
> }
> }
>
A division of a long integer with a known length of bytes by an integer of 8 to 1bits in a digit by digit division which that every digit is at least 8 bits is still missing.
This is trivial in C, but I'll see if we have to start a c programming race here.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! 88888 Dihedral <dihedral88888@googlemail.com> - 2011-11-20 11:12 -0800
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Ian Collins <ian-news@hotmail.com> - 2011-11-21 08:18 +1300
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Vincenzo Mercuri <vincenzo.mercuri@yahoo.it> - 2011-11-20 20:22 +0100
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! 88888 Dihedral <dihedral88888@googlemail.com> - 2011-11-20 11:23 -0800
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-11-20 15:03 -0500
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Kaz Kylheku <kaz@kylheku.com> - 2011-11-20 20:06 +0000
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! 88888 Dihedral <dihedral88888@googlemail.com> - 2011-11-20 12:13 -0800
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Ian Collins <ian-news@hotmail.com> - 2011-11-21 09:16 +1300
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-11-20 15:37 -0500
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2011-11-20 14:15 -0700
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Lew Pitcher <lpitcher@teksavvy.com> - 2011-11-20 13:45 -0800
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Malcolm McLean <malcolm.mclean5@btinternet.com> - 2011-11-21 00:44 -0800
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2011-11-21 12:44 +0200
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Lew Pitcher <lpitcher@teksavvy.com> - 2011-11-21 10:41 -0800
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! 88888 Dihedral <dihedral88888@googlemail.com> - 2011-11-21 00:53 -0800
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! "io_x" <a@b.c.invalid> - 2011-11-24 19:08 +0100
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Martin Ambuhl <mambuhl@earthlink.net> - 2011-11-20 17:32 -0500
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Keith Thompson <kst-u@mib.org> - 2011-11-20 14:55 -0800
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! 88888 Dihedral <dihedral88888@googlemail.com> - 2011-11-20 16:54 -0800
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Keith Thompson <kst-u@mib.org> - 2011-11-20 19:35 -0800
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-11-22 00:39 -0800
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Keith Thompson <kst-u@mib.org> - 2011-11-22 13:18 -0800
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-11-24 01:50 -0800
Re: Euler's constant jacob navia <jacob@spamsink.net> - 2011-11-21 12:45 +0100
Re: Euler's constant Vincenzo Mercuri <vincenzo.mercuri@yahoo.it> - 2011-11-21 13:54 +0100
Re: Euler's constant jacob navia <jacob@spamsink.net> - 2011-11-21 14:48 +0100
Re: Euler's constant Vincenzo Mercuri <vincenzo.mercuri@yahoo.it> - 2011-11-21 18:58 +0100
Re: Euler's constant Markus Wichmann <nullplan@gmx.net> - 2011-11-21 14:10 +0100
Re: Euler's constant jacob navia <jacob@spamsink.net> - 2011-11-21 15:36 +0100
Re: Euler's constant 88888 Dihedral <dihedral88888@googlemail.com> - 2011-11-21 07:08 -0800
Re: Euler's constant jacob navia <jacob@spamsink.net> - 2011-11-21 16:16 +0100
Re: Euler's constant Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-11-22 00:44 -0800
Re: Euler's constant Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-11-21 15:33 +0000
Re: Euler's constant Malcolm McLean <malcolm.mclean5@btinternet.com> - 2011-11-21 08:50 -0800
Re: Euler's constant "BartC" <bc@freeuk.com> - 2011-11-21 17:13 +0000
Re: Euler's constant James Kuyper <jameskuyper@verizon.net> - 2011-11-21 12:29 -0500
Re: Euler's constant Malcolm McLean <malcolm.mclean5@btinternet.com> - 2011-11-21 09:28 -0800
Re: Euler's constant Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-11-21 23:07 +0000
Re: Euler's constant Kaz Kylheku <kaz@kylheku.com> - 2011-11-21 17:29 +0000
Re: Euler's constant James Kuyper <jameskuyper@verizon.net> - 2011-11-21 12:36 -0500
Re: Euler's constant Keith Thompson <kst-u@mib.org> - 2011-11-21 13:46 -0800
Re: Euler's constant "io_x" <a@b.c.invalid> - 2011-11-24 19:08 +0100
Re: Euler's constant Markus Wichmann <nullplan@gmx.net> - 2011-11-24 20:31 +0100
Re: Euler's constant "io_x" <a@b.c.invalid> - 2011-11-27 11:24 +0100
Re: Euler's constant Markus Wichmann <nullplan@gmx.net> - 2011-11-27 12:09 +0100
Re: Euler's constant "io_x" <a@b.c.invalid> - 2011-11-27 13:33 +0100
Re: Euler's constant Lew Pitcher <lpitcher@teksavvy.com> - 2011-11-21 10:44 -0800
Re: Euler's constant Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-11-21 22:53 +0000
Re: Euler's constant Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-11-21 23:51 +0000
Re: Euler's constant 88888 Dihedral <dihedral88888@googlemail.com> - 2011-11-22 04:17 -0800
Re: Euler's constant 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-27 17:50 -0800
Re: Euler's constant Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-12-28 03:09 +0000
Re: Euler's constant 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-28 02:52 -0800
Re: Euler's constant Seebs <usenet-nospam@seebs.net> - 2011-12-28 18:17 +0000
Re: Euler's constant Dr Nick <3-nospam@temporary-address.org.uk> - 2011-12-28 18:49 +0000
Re: Euler's constant 88888 Dihedral <dihedral88888@googlemail.com> - 2012-01-04 04:44 -0800
Re: Euler's constant Robert Wessel <robertwessel2@yahoo.com> - 2012-01-04 12:33 -0600
Re: Euler's constant 88888 Dihedral <dihedral88888@googlemail.com> - 2011-11-21 15:07 -0800
Re: Euler's constant "io_x" <a@b.c.invalid> - 2011-11-24 19:08 +0100
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! 88888 Dihedral <dihedral88888@googlemail.com> - 2011-11-21 04:00 -0800
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Kleuskes & Moos <kleuske@somewhere.else.net> - 2011-11-21 12:37 +0000
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! 88888 Dihedral <dihedral88888@googlemail.com> - 2011-11-21 04:45 -0800
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Kleuskes & Moos <kleuske@somewhere.else.net> - 2011-11-21 13:35 +0000
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2011-11-22 00:01 +0200
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Kleuskes & Moos <kleuske@somewhere.else.net> - 2011-11-22 11:53 +0000
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Keith Thompson <kst-u@mib.org> - 2011-11-22 13:21 -0800
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Kleuske <kleuske@nowhere.net> - 2011-11-24 14:50 +0000
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! "io_x" <a@b.c.invalid> - 2011-11-24 14:08 +0100
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! "io_x" <a@b.c.invalid> - 2011-11-24 18:02 +0100
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Lew Pitcher <lpitcher@teksavvy.com> - 2011-11-25 15:31 -0800
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! 88888 Dihedral <dihedral88888@googlemail.com> - 2011-11-25 17:40 -0800
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Lew Pitcher <lpitcher@teksavvy.com> - 2011-11-25 22:03 -0800
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! 88888 Dihedral <dihedral88888@googlemail.com> - 2011-11-25 22:43 -0800
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Joe Wright <joewwright@comcast.net> - 2011-11-26 02:13 -0500
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! 88888 Dihedral <dihedral88888@googlemail.com> - 2011-11-26 19:40 -0800
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! 88888 Dihedral <dihedral88888@googlemail.com> - 2011-11-27 15:35 -0800
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Ian Collins <ian-news@hotmail.com> - 2011-11-26 20:22 +1300
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Lew Pitcher <lpitcher@teksavvy.com> - 2011-11-26 10:55 -0500
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Seebs <usenet-nospam@seebs.net> - 2011-11-28 08:32 +0000
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! superpollo <superpollo@tznvy.pbz> - 2011-11-26 12:11 +0100
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Lew Pitcher <lpitcher@teksavvy.com> - 2011-11-26 10:37 -0500
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! superpollo <superpollo@tznvy.pbz> - 2011-11-26 21:48 +0100
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Keith Thompson <kst-u@mib.org> - 2011-11-28 01:56 -0800
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Lew Pitcher <lpitcher@teksavvy.com> - 2011-11-28 13:34 -0500
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! James Kuyper <jameskuyper@verizon.net> - 2011-11-28 13:45 -0500
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Lew Pitcher <lpitcher@teksavvy.com> - 2011-11-28 13:50 -0500
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! James Kuyper <jameskuyper@verizon.net> - 2011-11-28 14:32 -0500
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Kleuske <kleuske@nowhere.net> - 2011-11-28 21:16 +0000
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Keith Thompson <kst-u@mib.org> - 2011-11-28 14:59 -0800
csiph-web