🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Still harping on about Epoch

Published August 05, 2008
Advertisement
Another productive couple of hours on Epoch today. I've added the real type to the language, so now floating point math is possible. Just for the hell of it I implemented Telastyn's benchmark algorithm in Epoch, with the following results:

entrypoint : () -> (){	debugwritestring(lexicalcast(string, pi()))}pi : () -> (real){	real(retval, 0.0)	real(denominator, 1.0)	boolean(isplus, true)	do	{		real(div, 0.0)		assign(div, divide(4.0, denominator))		if(equal(isplus, true))		{			assign(retval, add(retval, div))			assign(isplus, false)		}		else		{			assign(retval, subtract(retval, div))			assign(isplus, true)		}		assign(denominator, add(denominator, 2.0))	} while(less(denominator, 10000.0))	add(retval, 0.0)}


Execution time averaged 31ms on my machine. Not bad for a hacked up VM with no optimization support [smile]

Unfortunately, this turned up a couple of bugs in the built-in arithmetic operators. Specifically, in some cases the operands will be accidentally reversed, so instead of, say, 5 - foo, you get foo - 5. This is obviously a problem.

Eventually I'll hunt back through the code for the arithmetic operators and make sure everything is correct, but for now my brain is thoroughly fried.


You may also notice a couple of weird things in the above code, such as the trailing add(retval, 0.0) operation, or the fact that the div variable is somewhat superfluous. This just reflects areas of the language that aren't fully implemented; I still have to finish up a few various permutations of passing things around. Everything is a step forwards, though, and so far I haven't encountered any significant issues that would force me to redo parts of the VM.

I think the next step will be to tackle structures... that seems like a sufficiently big and scary thing to warrant another release once it's done [smile]
Previous Entry Epoch Release 2
Next Entry Running Thoughts
0 likes 1 comments

Comments

Telastyn
Nifty. In retrospect, my coworker's test is a pretty good test of basic flow control and math.
August 05, 2008 06:47 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement