Archived

This topic is now archived and is closed to further replies.

Samith

Ultra Mega Super Accuracy with Floats?

Recommended Posts

If I want, say, 100 decimals of accuracy with my variables (I want to be able to zoom reaaally far into the Mandelbrot Set ) do I have to specially program my own variable type? If so, how do I do this?

Share this post


Link to post
Share on other sites
If you want to zoom in that closely, do you really need to render the whole thing at the same time? It might be enough to calculate it for the very limited viewport you are considering, in which case double precision might be enough.

In any case, while I''ve never used this sort of thing myself, you don''t need to write your own types; there are free libraries available for this, like for example the GNU MP Bignum Library.

Share this post


Link to post
Share on other sites
you would usually use a method called "multiple precision floats"... this method allows you to do a part wise calculation of a large floating point value, by doing specified manipulations to the individual floats that represent it. Google it.

Share this post


Link to post
Share on other sites
quote:
Original post by Magmai Kai Holmlor
The x586 FPU has a 256bit floating point format. I think you''d have to write some FPU assembly to use them. This gives you a lot more precision than the typical float, double, or long double, but will come with a minimal performance penalty.

Hmmm.... I don''t think that''s right. IIRC, the i586 FPU represents floats internally with 80-bit precision, and offers the ability to load and store 32-, 64-, and 80-bit floats.


How appropriate. You fight like a cow.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
If you''re using a G4/G5, which you''re probably not, there are libraries that use the Altivec core to simulate a 1024-bit float. Since Altivec is a SIMD instruction set, the operations are very fast.

Share this post


Link to post
Share on other sites
it would hurt performance a bit, but technically there''s no limit to the percision you could use on this (until your memory runs out)

what you do is you have a set of, say, 256 bytes, but you treat it as two numbers (the integer and fraction)by shifting through the carry flag. treat the low 128 bits as the decimal. It''s kinda fun to do, might lose a little performace though, but from what you say you''re doing, it might not be noticable.

Share this post


Link to post
Share on other sites
Performance is really not much of an issue with what I''m doing. Since I just want to write a fractel viewer pretty much, so it''s not going to be fast anyway. This GMP thing actually looks pretty good, I might give it a try, considering the method Raptor85 posted could get pretty messy.

Share this post


Link to post
Share on other sites
quote:
Original post by Samith
Performance is really not much of an issue with what I''m doing. Since I just want to write a fractel viewer pretty much, so it''s not going to be fast anyway. This GMP thing actually looks pretty good, I might give it a try, considering the method Raptor85 posted could get pretty messy.


hehehe, i should write the code and post it here, i''ve done it with 32 byte integers before. (just as a toy, not in anything serious though)

Share this post


Link to post
Share on other sites
quote:
Original post by Sneftel
quote:
Original post by Magmai Kai Holmlor
The x586 FPU has a 256bit floating point format. I think you''d have to write some FPU assembly to use them. This gives you a lot more precision than the typical float, double, or long double, but will come with a minimal performance penalty.

Hmmm.... I don''t think that''s right. IIRC, the i586 FPU represents floats internally with 80-bit precision, and offers the ability to load and store 32-, 64-, and 80-bit floats.



I was thinking of the SSE registers, which means x786; and I''m not certain you can use all 128bits for a single number. 256/2 = 128, carry the 2 + x586 -> x786... or something.

Share this post


Link to post
Share on other sites
I don''t know much about different methods for representing numbers with arbitrary precision or >80bit floats. However, I know the problem with rendering fractals, which has a few properties (I take the Mandelbrot set as an example here):

- You KNOW that your numbers will never be larger than a relatively small integer (e.g. 4 in the case of the Mandelbrot set).
- Floating point representations are not very helpful, since you need N decimal points, regardless if the absolute value of a number is in the order 1.0 or 0.0000000000000001, for instance (floating point values only help where the numbers approach zero, which is the case for the least interesting part of the Mandelbrot set).

I think that it should be possible to device a pretty efficient fixed point format, where you only use very few bits for the integer part (e.g. 2-4 bits).

You may also consider the fact that you use complex numbers in your calculations, so perhaps a polar format may be more appropriate than a standard cartesian format (addition may be tricky though). I don''t know if it would buy you any advantage in terms of binary representation/computation.

Share this post


Link to post
Share on other sites
Raptor85, please do post your code!

marcus256: I can avoid having to implement it with polar coordinates by just calculating for the real part and calculating for the imaginary part. This is a lot easier, if you ask me.

Share this post


Link to post
Share on other sites