Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

About number precision on Codea

edited April 2013 in General Posts: 4

Hello everyone.
I am new to Codea, I bouth it just few days ago.
I started by studying the examples and my first program has been a new Mandebrot set drawing program.
I realized that at a not so high zoom level, there are floating point precision artifacts.
What is the floating precision of Codea? The Lua manual states that numbers all are of a unique type, with double precision, but to me it seems there is no evidence of that.
There is some way to get at least a double precision for float variables?
Thank you in advance.

P.S.: sorry for my english.

Comments

  • dave1707dave1707 Mod
    Posts: 8,624

    .@Rosso5 Codea uses 32 bit precision which gives 6 or 7 digits past the decimal point. Do a forum search because this was brought up previously.

  • Posts: 4

    Thank you. If I am not wrong, 32 bits correspond to single precision.
    I tried to make a search, I saw that stated once, but I would like to be sure and to know if there is some way to increase the precision, otherwise a low of programs would be not-realizable.

  • dave1707dave1707 Mod
    Posts: 8,624

    There isn't any way to increase the precision. I would like to see an option to use 64 bit for accuracy or 32 bit for speed. See this discussion.
    http://twolivesleft.com/Codea/Talk/discussion/1294/calculator-and-scale-10/p1

  • Jmv38Jmv38 Mod
    Posts: 3,297

    Hi @Rosso5. If you do things that really need double pecision (maths or physics), it should be quite easy for you to implement yourself any precision you need? Just define your own +,*,-,/ with the number of bits you want?

  • Posts: 489

    Hello @Rosso5. The page on the Codea Wiki here may be of interest to you.

  • Posts: 4

    @mpilgrem: thank you, this gives a definitive confirmation.

    @Jmv38: Thank you. I am not sure this can be made in easy way, I have not experience on that, but I think I could try, in case I really need it. In any case, it seems quite strange to me that a very basic thing like the precision of numeric variables in a programming language needs to be implemented by the final user, it should be planned in the programming language specification. And generally it is needed not only on basic operation (+, -, *, /), but also for powers, exponential, logarithms, trigonometric function, etc.

  • Posts: 51

    In the discussion he referenced @dave1707 said, "it would be nice if Codea used 64 bit precision, but I guess 32 bit is good enough for what's being done now." My take on this is that 32-bit precision limits what is being done now.

    I've tried implementing large number arithmetic, and still have trouble with division. It's harder than you'd expect!

    So I'd like to see 64-bit reals made an option too. Most projects don't need it, but there are some that would.

    Ever hopeful...

  • Posts: 4

    Yes, it would be very useful to have at least an option to define some double precision variables if needed.
    Mandelbrot set explorer is an example (for the zoom over a certain amount, not so high), another one is a program performing ray-tracing.

Sign In or Register to comment.