It looks like you're new here. If you want to get involved, click one of these buttons!
I have two variables x,y that are calculating very small numbers between 0 and 1 depending on variables a and b. It is understandable that the values are going to sometimes come up as "nan". However, when I set a and b to values that make x or y a small number, then a value that computes nan for x or y, then set a or b back to what should compute a small number again, the values stay as nan. The project is running while doing those steps. Can someone try this out to see if it's a bug, or just a problem in my code? Or teach me how to round to the nearest nth?
Comments
@PlatniumFrog If you want to check if a value is
nan
, then check the value against itself. If it's not equal to itself, it'snan
.If you still have problems, post the code
Could I have a function that rounds an oversized decimal to the maximum number of decimal places a number can have in codea/lua?
Here's a routine. Pass it a number and how many decimal places you want. Just figure out how many decimal places you want. If you always want a fixed number of decimal places, replace dp with that value.
EDIT: The number of decimal places you can have will depend on how many digits are before the decimal point.
EDIT: With this routine, it looks like you can have a total of 14 digits.
Here is what I have been trying to build.
The forum post handler leaves out multiplication stars and auto detects code which personally is slightly annoying
Ths means that to use this while in the codea editor, you will have to insert a multiplication star inbetween joined variables.
Obviously all varibles are defined in the setup function so you will have no trouble.
Code starts here and ends before "code stops":
Code stops
Cool right? Anyway, the reason behind all this is that I am trying to get the Mandelbrot formula right. You can copy/paste this if you want to check it out
@PlatniumFrog Anytime you want to post code, put 3 ~'s on a line before and after the code so it formats correctly. I added them to your code above. There is a Mandelbrot example included with Codea. You can look at it for the formula.
I knew that, but I thought that it just edited the sprite/icon. Am I wrong?
The Mandelbrot example creates the Mandelbrot image. You can change the limit of the Mandelbrot calculations. I have some code for Mandelbrot that allows you to change the limit and also zoom in on selected areas.
@PlatniumFrog See this link for a better Codea Mandelbrot program.