Code center > Darwinbots3

Make v3 support decimals

<< < (3/4) > >>

Botsareus:
How about something more simple:

Just round each number to the 5th or the 4th decimal place. This way stuff like 1/0.001 will be in range...
Less pain, although small numbers will be reset to 0.

Numsgil:
I've been thinking about that too.  The upside is that it would allow things like sqr to return more interesting results.  But in the end it isn't much different from the integer stack.  So I think it's probably the most realistic option.  I could be persuaded, I think.

Trafalgar:

--- Quote from: Numsgil ---I've been thinking about that too.  The upside is that it would allow things like sqr to return more interesting results.  But in the end it isn't much different from the integer stack.  So I think it's probably the most realistic option.  I could be persuaded, I think.
--- End quote ---

Side note: I'd rather have an x^y operator which allows fractions in y than a sqr operator. (Since the square root of x is x^(1/2), and the cube root of x is x^(1/3), etc)

Numsgil:
What if I just give you a cube root operation?

BTW, I think there's a way to get at a cube root using square root.  Wikipedia had this on the cube root page for a calculator:

    * Press the square root button twice.
    * Press the multiplication button.
    * Press the square root button twice.
    * Press the multiplication button.
    * Press the square root button four times.
    * Press the multiplication button.
    * Press the square root button eight times.
    * Press the multiplication button...

Maybe it would work in DNA, too.

Peksa:
Well, here it is. It took me way too long make, so I hope it helps. If not, at least I've proven it can be done. It's accuracy varies quite a bit. I haven't done extensive testing on it's limits etc.

It takes the first number (20) and approximates it's cube root and stores it in 61. It displays 3 decimals. Ie. for 1331 (11^3) it gives 10882 (as opposed to 11000) and for 20 it gives 2693 (should be 2714).


--- Code: ---20
10000 mult sqr
10000 mult sqr
dup
10 mult sqr
10000 mult sqr
mult 1000 div dup

10 mult sqr
10000 mult sqr
10 mult sqr
10000 mult sqr
mult 1000 div 61 store
--- End code ---

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version