?

Log in

No account? Create an account
the coproduct of doom [userpic]

another silly function for y'all

May 10th, 2003 (01:31 am)

public real function add(real x, real y)
	{
	if(x==2 and y==2)
		{
		return 5;
		}
	else
		{
		return x+y;
		}
	}

Comments

Posted by: Grayden (grayden)
Posted at: May 11th, 2003 08:42 pm (UTC)
Ummm....

Three Sir!

Posted by: The Golden Boy with the Teflon Suit (kraant)
Posted at: May 12th, 2003 10:52 pm (UTC)

Aren't reals not gurranteed to be directly equivalent to an Int even when you think they are because of rounding errors?

Posted by: the coproduct of doom (oonh)
Posted at: May 12th, 2003 11:15 pm (UTC)

Well, the function above is supposed to be implemented in nickle, so that I can/could examine what number theoretical properties it has. ("so Interrogator, I could bend into your torture and accept that the statement "2+2=5", but that would make + nonassociative over the reals. how do you feel about that?").

When you say "real", I think you mean "double", and my answer is that that implementation is highly
architecture dependent. (I recommend ruffling through IEEE definitions of these data types)

Posted by: The Golden Boy with the Teflon Suit (kraant)
Posted at: May 13th, 2003 11:10 pm (UTC)

Aaah so it's not floating point...

It's using genuine bonafide reals.

Heh, interesting seeing C syntax there then...

Have you looked at lisp or scheme?

Posted by: the coproduct of doom (oonh)
Posted at: May 18th, 2003 10:34 pm (UTC)

I've played around with lisp and scheme. I haven't wrapped my head around a purely functional language yet (though logical combinators are effing sexy).

I like playing with nickle for mathematical whatsits.

5 Read Comments