FRACTAL REPORT 10







Arthur C. Clarke's novel The Ghost from the Grand Banks, featuring the Mandelbrot set, cryonics, and the Titanic was published by Gollancz in October, and Bantam in December, 1990



Contents of printed edition:

Wallpaper Peter Moon 2

Julia Sets - Part II Dr Ian Entwistle 4

Fractal File Formats Larry Cobb 7

More Martin's Mappings Dr Hugh N. Daglish 8

Bifurcated Sounds Leon Heller 13

Beyond Mandelbrot Tom Marlow 14

Ginger Bread Men Tom Marlow 15

Feigenbaum Diagram in C for the PC Leon Heller 16

Editorial John de Rivaz 17

Announcements John de Rivaz 18

Fractal Report is published by Reeves Telecommunications Laboratories,

West Towan House, Porthtowan, Truro, Cornwall TR4 8AX, United Kingdom.

Volume 2 no 10 First published August 1990. ISSN applied for.



Editorial

At the end of volume 1 we had over 400 subscribers, and that the total number of subscribers for that volume must now be well over 400 as we continue to sell it. The fact that we have only 320 or so subscribers to the current volume may suggest that interest in fractals cannot be maintained over a long period. The initial take up on enquiries for volume 1 was of the order of 40%, which is very high for an operation of this type. But if the replenishment rate is less than the new intake each year, then the lifetime of the newsletter will definitely be finite! Subscribers are reassured though, that when and if the time comes the newsletter will be wound up properly, with a "last volume," and not just suddenly stopped leaving unfulfilled subscriptions, as do many small DTP computer journals.

I anticipate Fractal Report will run to several volumes at least, and I would like to keep the early ones in print. The possibility exists of offering early ones in microfilm, if microfilm readers can be obtained and offered to subscribers at a reasonable price. Any help on this idea would be appreciated.

Under Announcements we cover further Fractint news, and the current version, 13.0, which although massive in size and number of features, is beginning to show a sort of sameness that may be dulling people's initial enthusiasm.

Another avenue for exploration may be to graft a program like Microsoft Flight Simulator onto fractal landscapes or 3D sets and mappings. Flight Simulator has a facility for scenery disks to enable flight over different countries, so anyone who knows how these are made up may be able to give us a clue as to how to input fractal images instead.

We still await an article explaining clearly how to make fractal music. Many readers have asked for this.

A regular publishing schedule for Fractal Report is now anticipated, with issues appearing at the end of the following months:

March, May, July, September, November, January.

The cover date will be the following month, so for example the issue that appears at the end of July will be cover-dated August. Renewal notices will go out with the January issue. Issues will go to press about five weeks before despatch. Time sensitive copy should never be left until the last minute though, as each issue is gradually filled during the month. If there are problems that disrupt this schedule, more frequent publication will be used until it is re-established.

There's Money in Chaos

I may have mentioned this before, but I feel that it is worth mentioning again. There are many computer magazines (over fifty at a quick count) and computer user groups, all of which require articles. Fractal Report contains programs and algorithms that can be adapted to most makes of computer. Once you have got such a program up and running on your machine, why not try submitting it as an article to a computer magazine? (Preferably with due acknowledgement to Fractal Report and the original author, mentioning the address for sample copy.) Most news stand magazines pay quite highly for articles now, and the payment could certainly cover your Fractal Report subscription and leave you some change afterwards.

I would also like to start a regular feature Readers' Published Work listing any articles that have appeared in news stand magazines mentioning Fractal Report. Therefore any reader who gets such an article printed is asked to send (preferably) a photocopy of the published article and/or the details of the magazine it appeared in.

This is another deal where everyone benefits. The reader/author gets money, Fractal Report gets extra publicity, and the target magazine gets an interesting article with program AND a mention in Fractal Report.

Fractal Prose

At the outset of this project I suggested the possibility of Fractal Prose and Fractal Poetry. I have an idea for the former which may be relevant. One would need a long list of common first names and last names, sufficiently long so that the probability of two coming together more than once is slight. Then a basis for a novel is devised on the main problem facing those proposing cryonics - if you can get Mr A to agree, he may not want to go if he cannot afford to take Mrs A, and she may not opt for the process if she can't take her mother, who won't do it unless she can take her spouse and other children and so on. A list of situations with suitable verbs and nouns etc would be needed, and the "story" could proceed for ever.

Postal Inflation

I have heard rumours that the Post Office plan the most savage increases in postal prices since the introduction of the modern postal service by Rowland Hill. The increase in first class letters will be more than what it cost to post a first class letter only a few years ago! I am hopeful that I can maintain my prices of 10 (UK) for newsletters in the face of this increase by way of further economies and improved circulation. If the content of Fractal Report can be maintained over the next issues, then we should be able to retain and expand our readership. Rather than put cassette prices up, we will probably start mailing them second class or parcel post.

For what it's worth, my view of the Post Office is that they should look to economies internally instead of increasing prices so dramatically. Do people really need two deliveries per day? How about a 3rd class rate for bulk advertising mail, to be delivered during slack periods only? As there is no delivery on Sunday (and we don't need one) do we need collections on Saturdays? I hope that many Fractal Report readers will write to their MPs making constructive suggestions about how to keep postage costs down. For widely spread minority groups like fractal enthusiasts, these continuing increases are a serious threat.

If everyone could act as vigorously against rising costs as they do against poor wages, then we would have a far healthier economy.



Announcements

CAD Newsletter

Jo Gedrych has a nice little newsletter for those who use Sun Workstations and high specification PC systems. Entitled "topics" it describes various products for the professional CAD user. Consisting of 4 A4 sides in full colour, it comes out quarterly and is free, but is obviously intended for business users rather than hobbyists. (Intelligent Computer Solutions Ltd., London House, 26-40, Kensington High Street, London W8 4PF.)

Video Services

Mr Nigel Woodhead, of Scarab Software, 38, Midship Point, West Ferry Road, London E14 8SW, has expressed an interest in helping with the Fractal Report video, and says that he can provide the following services to anyone interested, by negotiation, but extremely competitively.

Custom Video Services. Transfer from any format PC image program to PAL VHS videotape, either single frame or real time, plus access to further editing and production services at a professional London video company.

Animation, graphics or special effects and titling - available on disk, videotape, using supplied or created artwork, including scanning from video frames or hard copy.

Fractint Corner

We must all offer a vote of thanks to Robin Harvey who sent me Fractint 12.0, and Cade Roux who sent Fractint 13.0. Robin Harvey and a number of others pointed out that Fractint is public domain rather than shareware. I mailed copies to Jo Gedrych and Adam Case, whom I hope passed them on to any enquirers.

Those people who had already obtained version 9.1 from Jo and Adam are asked to send in another blank disk and return postage if they want the latest version. Due to the volume of mail, they may not be able to let everyone know.

This program also contains a formula input system. You merely type in a formula, like:

Mandelbrot(XAXIS) = {

z = Pixel: z = sqr(z) + pixel, |z| <= 4

}

and your fractal can be produced with the full set of features of Fractint! For full details see the Fractint documentation.

User's formulae may be added to the next release of the program, with attribution in the .frm file. Let's see plenty from Fractal Report readers. Like Longevity Report readers, Woody Allen prefers to live on in his apartment, but for those of you who are happy to live on in your works, then this is your chance of immortality!

Fractint 13.0 also has a facility whereby one can create a "virtual screen" of up to 2048x2048x256 and print to a HP laserjet compatible printer. The resulting images equal or exceed those produced as black and white prints in glossy fractal books. If Larry Cobb can get his colour printer to print these images in colour, then surely this will add a new lease of life to his competition. I tried a Julia set, and it took six hours to produce and one and a half hours to print! (And that was with a reasonably fast PC - a standard PC would take several days, and Digital Precision's QL PC Emulator several weeks!)

Fractint is written in C and assembler. The source code for both is available, and therefore it should be possible to get versions going for other machines, such as the Amiga, ST and Archimedes. But this task should only be considered by people with a lot of experience and/or time.

Fractint is regarded by its originators as "Stone Soup Software" and here is part of the manual that explains the concept:

Stone soup with pixels: the authors

Once upon a time, somewhere in Eastern Europe, there was a great famine. People jealously hoarded whatever food they could find, hiding it even from their friends and neighbours. One day a peddler drove his wagon into a village, sold a few of his wares, and began asking questions as if he planned to stay for the night.

[No! No! It was three Russian Soldiers! - Lee Crocker] [Wait! I heard it was a Wandering Confessor! - Doug Quinn]* [Well *my* kids have a book that uses Russian Soldiers! - Bert] [Look, who's writing this documentation, anyway? - Monte] [Ah, but who gets it *last* and gets to upload it? - Bert]

"There's not a bite to eat in the whole province," he was told. "Better keep moving on."

"Oh, I have everything I need," he said. "In fact, I was thinking of making some stone soup to share with all of you." He pulled an iron cauldron from his wagon, filled it with water, and built a fire under it. Then, with great ceremony, he drew an ordinary-looking stone from a velvet bag and dropped it into the water.

By now, hearing the rumour of food, most of the villagers had come to the square or watched from their windows. As the peddler sniffed the "broth" and licked his lips in anticipation, hunger began to overcome their scepticism.

"Ah," the peddler said to himself rather loudly, "I do like a tasty stone soup. Of course, stone soup with CABBAGE -- that's hard to beat."

Soon a villager approached hesitantly, holding a cabbage he'd retrieved from its hiding place, and added it to the pot. "Capital!" cried the peddler. "You know, I once had stone soup with cabbage and a bit of salt beef as well, and it was fit for a king."

The village butcher managed to find some salt beef...and so it went, through potatoes, onions, carrots, mushrooms, and so on, until there was indeed a delicious meal for all. The villagers offered the peddler a great deal of money for the magic stone, but he refused to sell and travelled on the next day. And from that time on, long after the famine had ended, they reminisced about the finest soup they'd ever had.

***

That's the way FRACTINT has grown, with quite a bit of magic, although without the element of deception. (You don't have to deceive programmers to make them think that hours of painstaking, often frustrating work is fun... they do it to themselves.)

It wouldn't have happened, of course, without Benoit Mandelbrot and the explosion of interest in fractal graphics that has grown from his work at IBM. Or without the example of other Mandelplotters for the PC. Or without those wizards who first realized you could perform Mandelbrot calculations using integer math (it wasn't us - we just recognize good algorithms when we steal--uh--see them). Or those graphics experts who hang around the Compuserve PICS forum and keep adding video modes to the program. Or...

* Does this refer to the Doug Quinn who is the founder of the Cryonics Society of Canada, does anyone know?

Amiga News

Cade Roux, addresses in last issue, advises that some of his prices for Amiga products have been adjusted downwards, so readers are asked to request his latest list before ordering. Some new items have also been added. The first edition of his Amiga disk Ami-FX, Amiga Fractal Exchange is being put together now, and includes animated sequences of a 3-D Sierpinski tetrahedron rotating and bouncing, a full colour Julia walk, and an animation based on changing the boundary value of the algorithm used to generate Mandelbrot Set images.

Fractals in the News

Mr Anthony Bayliss enquired on 25 May re Fractal Report, his interest in fractals and chaos being inspired by a television programme called The Late Show. Has anyone got a VHS video of this I could borrow, please? Apparently Dr Benoit Mandelbrot was interviewed on the programme.

Mike Zehse is a Longevity Report reader who lives in Peckham and is well known for his humorous letters. One of his favourite pastimes is scouring London's dustbins for thrown out newspapers, and one of his finds was a report on fractals in The Sunday Times of 29 April.

Rebecca Fowler described a new fractal culture. This includes T-shirts with x2 + c = x emblazoned on their arms. (I wonder what happened to the imaginary component!) These are marketed by a company called K-OS, who also plan Tripatrom a fractal computer game with no end, no losing and no winning. Founder James Ashbey is quoted as stating "With fractals, a pattern is always just at its most complex as a new order is reached. Just as we are getting to the end of this century we are reaching the maximum complexity of chaos and turbulence." (Why? The numbering of the years is purely arbitrary. The turn of the century is only meaningful if people choose to make it so. Come to think of it, people are motivated by the publishing media, so I suppose they will make it so! If the results from the space telescope make it possible to give an accurate age to the universe, then only this could give a sensible datum to a numbering of years, but even then, one could argue that the orbital elements of the Earth are still arbitrary in this context. And of course it is only half the age of the universe as a whole. {?I think!} If the Quantum Theory gives a smallest possible moment of time {I think 10-24 of a second has been suggested} then measuring the age of the universe in these units, with a suitable multiplier prefix to make the numbers manageable, may be the best way if you are looking into any deep meaning in numbers. There again, if whole numbers have significance, why choose the decimal system. Perhaps the significant whole numbers are those when they are expressed in a system to base 131, for example!)

Also mentioned is Chaos comic, and an expression "I'm off on a fractal" is reported to be in common (if hardly accurate) usage to mean the speaker is going to let his thoughts follow one another in a random fashion.

Ms Fowler appears to have discussed all this interest with Dr Mandelbrot who is directly quoted as saying "I view myself to be a scholar removed from these movements."

Another video

New reader maths teacher Costel Harnasz tells us that he has seen a supplement to Scientific American called Scientific European. (April). In it there was an advertisement for a video entitled Fractals: an Animated Discussion, However he sent no further details. He also sent in a colour photo of his Casio 7000G graphic scientific calculator showing the Mandelbrot set. He said it took two hours to plot it, and 24 hours to plot map 44 in The Beauty of Fractals.

Amygdala News

I received issue 20 on 19 June, and it's eight pages contained two mathematical articles: Computing Sections of the Cubic Connectedness Locus and Tutorial on Complex Analytic Geometry. So this is where those who require this material should go. The address is Box 219, San Christobal, New Mexico 87464, U. S. A. Their circulation is up to 953 subscribers, which perhaps explains why they charge $30 for announcements, and didn't mention Fractal Report despite our coverage of their magazine. A current subscription to Amygdala, covering issues 19-28, costs $45 to UK readers, and Amygdala will accept Visa and MasterCard (Access etc). Credit cards usually give a fairer rate of exchange than banks.

Slide sets are $32 extra. Do not underate these slides. If you could get or make an automatic back-projector (and have somewhere suitable to put it) they would make a great decoration! They are slides of views from the Mandelbrot Set and other fractals, and do not necessarily relate to material in the accompanying newsletter, although there are usually short text descriptions of what is on each slide.



Amygdala will also supply the Zooms cassette, but the price to UK readers is $35.20 including insured airmail on top of which, if you are unlucky, you will have to pay a mixture of UK taxes, charges and duties. The advantages of getting it from Amygdala it is quicker than via Fractal Report. We keep the price down by leaving it until we have a waiting list before ordering so we don't have to hold stock, and by ordering via surface mail and at a special bulk rate so the duties and taxes are worked out on a much smaller base figure. The price people pay for saving a lot financially by getting it from us is a long wait!

Music News

Mr Kobus Nieuwmeijer performed live on Saturday 16 June at London's Earth Signals - The Chaos Happening Amphalos Gallery. They used a Mac for real time fractal music (with help from Mr A. McLean) and an Atari with midi (Array) stored in a seq. He says it went down well. We still have a few of his Fractal Fissures cassettes left at 4. (post included.) - First come, first served.


Fractal File Formats

by Larry Cobb

All graphics files tend to have one thing in common - they take up a lot of disk space, and fractal images are no exception! If a VGA image were represented by one of a possible 256 colours for each pixel on a VGA screen, then the file size would be 480 x 640 bytes, requiring a minimum 307,200 bytes of disk space. (In practice there would be extra bytes needed to describe the graphics parameters.)

The current version of my Fractal Investigation Program, DRAGONS 2, uses a relatively simple method of reducing the file size called Run Length Coding (RLC). Raster scanned images often have areas of constant colour and so, instead of describing the screen point by point, RLC defines the colour and then says how many adjacent pixels have that same colour. In this way a run of 256 pixels with the same colour can be compressed from 256 bytes to 2 bytes. Of course this is an extreme example but file compressions of 5 are common with fractal images. The weakness of this method is that if the colour changes every pixel, RLC actually uses more space that the uncoded data - two bytes per pixel instead of one.

There are more powerful compression techniques that construct a look-up table of the patterns that are present in the data and assign a code to each. When the pattern recurs in the data, it is only necessary to look up the appropriate code in the table and send this. One system using this technique is called the Graphics Interchange Format (GIF) which was designed by CompuServe. They run a large bulletin board or forum service and so have a particular interest in reducing file sizes and hence storage requirements. Also, when you are paying telephone and connection charges, with data rates around 1200 baud, smaller files can save a lot of money!

The GIF standard has many attractive features, including:

It is one of the most efficient compression techniques available, producing files that are typically half the size of an RLC file.

It is a hardware independent specification and decoders are available for most popular computers.

It is freely available to all programmers to use without licence or royalty payments.

It is widely recognised and more and more programs use it as their file specification, (eg Autodesk's Animator).

Even if it is not directly supported by a graphics program, there are many Shareware converters available. For instance, I have used VPIC to convert GIF to Dr Halo CUT format so that I can add text to a fractal image. Also, there are many Shareware programs that can print and produce slide shows using GIF files. One of the best I know for the IBM PC is called CSHOW.

And of course it is the best way to send fractal files all around the world on the CompuServe network to compare results with other enthusiasts.

Perhaps its main drawback is its complexity - it is not easy to write coders and decoders for the GIF standard. But if you want more information to allow you to write your own coder and decoder, I can supply a copy of the GIF 87a specification on floppy disk or you can get it from CompuServe directly. Also available are the Shareware programs for IBM compatibles mentioned above, namely VPIC and CSHOW. Please remember that Shareware is not free. You can try out these programs for a short time but, if you continue to use them, you must send a registration fee to the author. They are very reasonably priced though, and supporting good Shareware authors encourages them to write more programs.

As I mentioned before, DRAGONS 2 uses RLC files but also on the GIF disk set is a DRAGONS to GIF converter. Watch out for a new release of DRAGONS in the Autumn that will support both standards and have other enhancements - DRAGONS 3 is coming soon!

Finally, I would recommend that anyone who has a modem should try the CompuServe network. There is a whole forum devoted to computer art (GO COMART), a section of which is devoted to fractals. The Fractint program is widely used here and the latest version (13?) can be downloaded, as can any of the graphics files. If you get bored with fractals, there are lots of other forums to explore including computer hardware and games. In fact there seems to be a forum on just about every topic but the bias is towards the American user at the moment (weather, travel etc). It becomes so addictive searching through the forums that you have to keep a careful eye on the connection time to avoid the charges piling up.

In future I intend to upload the fractal competition prize winner to the Computer Art Forum. I think our images are every bit as good as the ones I've seen on CompuServe. Not only national but international fame awaits the winner, so keep those entries coming!

If you are tempted to try CompuServe, you can contact them (free) on 0800 289 378. An introductory kit costs 29.95 but comes with $25 of credit. And if you want to send me a message on the network, my user id is 100016,421.

I would be particularly interested to hear how users of computers other than the IBM PC compatibles get on with GIF files, either by electronic mail or the more conventional post. GIF should be a way to break some of the hardware barriers but I have only tried it on IBM Pcs.

The special GIF software package for IBM PC compatibles contains:

ITSAGIF.EXE DRAGONS to GIF converter for DRAGONS 2 users

GIFSTD.TXT A description of the GIF 87a file standard

VPIC.EXE A Shareware GIF display and format conversion program for IBM PCs

CSHOW.EXE A Shareware GIF display, printing and slideshow program for IBM Pcs

together with the documentation files and as many fractal GIF files as I can fit onto the disks.

Send a cheque or PO for 5 to cover costs to:

Larry Cobb, Bay House, Dean Down Drove, Littleton, Winchester, Hants, SO22 6PP and don't forget to say whether you want 5 or 3 inch disks.

Send details of your Mandelbrot or Julia set fractals for the competition entries to the same address, please. Despite my pleas, there have been no Julia Set entries for the competition.



Julia sets are slightly more difficult to find, so here are some tips to help those who would like to try. The trick is to use the Mandelbrot set as a map to where the Julia dragons are hiding. Find the co-ordinates by moving a cursor around the edge of the Mandelbrot set, in and out of the infinite sprouts or caves. This will give you the complex c value that is needed to calculate the Julia set at this point. If you move deeper into the set (the black inner area) then the Julia set becomes fatter. These are the best ones for "tiling" - a method where the inside of the set is coloured depending on the attractor or root value. If you cross the boundary into the area of chaos, the dragon begins to break up in "Fatou" dust. This too gives an attractive result.

The number of filaments which lead from the Mandelbrot sprout, determines the number of heads the dragon has, while the swirls of the filaments are transferred to its writhing body. So, with a little experiment with the Mandelbrot map, some fascinating mythological creatures can be found. Julia sets also have the advantage of being quicker to calculate, giving you more time to get some spectacular results.

The winner will receive a high resolution, colour print of their entry and international fame!


BIFURCATED SOUNDS

by Leon Heller

Following a suggestion in Becker and Dörfler's book, Dynamical Systems and Fractals, that the reader presents the values generated by a Feigenbaum-type system acoustically, as a series of tones, I wrote the following little program, using the Zortech C compiler, for my Opus PC clone.



















































































































Try an initial value of 0.5. Growth factors of more than 3.57 result in chaotic output.



The results don't sound particularly musical (Babbage, my Burmese cat, started howling!), and the recurrent clicks resulting from the PC internal interrupt are a bit annoying, but listening to chaos makes a change!



The first sound tone function parameter is the number of cycles, and the second and third parameters are the output up time and down time, respectively. Making them the same as the number generated by the recurrence formula ensures a 50% duty cycle.



With a MIDI interface and a synthesiser, something more interesting could no doubt be generated. Perhaps someone with some decent musical hardware could follow this up.



Incidentally, the aforementioned book has some material relevant to John Topham's article on bifurcation diagrams, in the region where the behaviour becomes chaotic.


FEIGENBAUM DIAGRAM IN C FOR THE PC



The following program is a translation into Zortech C of the Pascal program on page 38 of "Dynamical Systems and Fractals" by Becker and Dörfler. It is written for a PC with EGA (640 X 350 resolution). A monochrome, white on black, image is produced.

Some of the images produced differ from those reproduced in the book, presumably because Zortech C, like most C compilers, uses double precision 64 bit floating point arithmetic routines.

When I've worked out how to access 8086 interrupts from the INMOS transputer development system, I'll be able to run this type of program (translated into Occam) on an array of transputers, without the need for an expensive transputer-based graphics system, although I hope to have such a system before long.

If anyone tries this program, and doesn't have Becker and Dörfler's book, the following values will get you started:

Left = 2.5, Right = 2.8, Top = 1.4, Bottom = 0.9, Invisible = 50, Visible = 50.

With these values, I was intrigued to see a ghostly parabola in the chaotic region on the right of the image. Of course, the generating function is parabolic, but I don't see why the "ghost" appears. Has anyone got an explanation for this?

#include <stdio.h>

#include <math.h>



struct {

int ax;

int bx;

int cx;

int dx;

int si;

int di;

int cflag;

} regs;



double modf();



#define XSCREEN 640

#define YSCREEN 350



/* globals */

float left, right, bottom, top;

int visible, invisible;



main()

{

/* get input values from user */

printf("Left: "); scanf("%f", &left);

printf("Right: "); scanf("%f", &right);

printf("Bottom: "); scanf("%f", &bottom);

printf("Top: "); scanf("%f", &top);

printf("Invisible: "); scanf("%d", &invisible);

printf("Visible: "); scanf("%d", &visible);



/* set video mode to EGA graphics (640X350 pixels) */

regs.ax = 0x0010;

int86(0x10, &regs, &regs);



/* plot Feigenbaum diagram */

feigenbaum_iteration();



/* wait for keypress */

getch();



/* reset video mode to mono alphanumeric */

regs.ax = 0x0002;

int86(0x10, &regs, &regs);

}



/* plot point at co-ordinates (x, y) */



plot(x, y)

int x, y;

{

regs.ax = 0x0C0F;

regs.bx = 0x0000;

regs.cx = x;

regs.dx = y;

int86(0x10, &regs, &regs);

}



/* plot Feigenbaum diagram */

feigenbaum_iteration()

{

int range, i;

float p, k, deltax_per_pixel;

deltax_per_pixel = (right - left) / XSCREEN;

for (range = 0; range != XSCREEN; range++)

{

k = left + range * deltax_per_pixel;

p = 0.3;

for (i = 0; i != invisible; i++)

p = p + k * p * (1 - p);

for (i = 0; i != visible; i++)

{

set_universal_point(k, p);

p = p + k * p * (1 - p);

}

}

}



/* machine-independent function for setting a pixel with real co-ords */



set_universal_point(xu, yu)

float xu, yu;

{

float xs, ys;



xs = (xu - left) * XSCREEN / (right - left);

ys = (yu - bottom) * YSCREEN / (top - bottom);

plot(round(xs), round(ys));

}



/* round a real value */

/* modf extracts integral and fractional parts of a real number */



round(x)

float x;

{

double d1, d2;



d1 = modf(x, &d2);

if (d1 >= 0.5)

return ((int) d2 + 1);

else

return ((int) d2);

}



Leon Heller,

30 Baldslow Road,

Hastings,

East Sussex TN34 2EY.

Tel: (0424) 714790

Editorial Note: Although we don't normally print C programs, as this article is clearly aimed at putting a well known algorithm into C I hope that we won't offend readers who don't use the language. As it was supplied on disk, we were able to fit it in without overuse of paper.


This page hosted by Get your own Free Home Page
Hosted by www.Geocities.ws

1