Re: The "spinoza" programming language
- From: spinoza1111 <spinoza1111@xxxxxxxxx>
- Date: Mon, 10 Mar 2008 19:12:39 -0700 (PDT)
On Mar 11, 4:30 am, Mike <m.fee@xxxxxxxxxxxxxxxxxxxx> wrote:
In article <b5421ac0-ec36-4a13-814a-4e040da51...@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>, spinoza1...@xxxxxxxxx says...
On Mar 10, 10:28 pm, "Stephen Howe" <sjhoweATdialDOTpipexDOTcom>
wrote:
Isn't that going to make a statement of the form:
x = sqrt(2);
take rather a long time to return, or does the compiler somehow 'know'
exactly how many digits are required? Some sort
of Haskell-like lazy evaluation perhaps?
Mike
Spinoza:
Yes, there are serious problems with implementation of unlimited
floating point.
The least of which is that number cannot be expressed as a irreducible
fraction. It is irrational (in the mathematical sense of the word)
Spinoza:
However, the OO approach means that the representation
is encapsulated and could, as such, be a formula and not a number.
You have not solved anything.
You have deferred the problem.
At some point the number may need printing out in base 10 format - how are
you going to print out a number with an infinite number of digits?
You're not gonna, of course. But the OO approach can warn you whether
the number has a finite representation in a given base.
Integers can always be represented.
If one is divided by three, then the calculation of .333... using base
10 will of course have to return the exact answer as 1/3.
What's better? Having an "unlimited" exponent and mantissa, or having
to do (or failing to do) elaborate numerical analysis to make sure
your answers are sensible?
The question is whether there are algorithms for detecting whether a
given calculation has a repeating or transcendental result, given two
non-repeating and non-transcendental values. Hmm, I'm no
mathematician, but it seems that this is only the case for division
and multiplication.
integer times integer is integer. If i>j, and i and j are integers,
the result is integer. Etc.
For common functions, where a transcendental or repeating value must
occur, you will have to decide on a precision.
But the object itself could return whether its value is precise.
Fun values would include epsilon, for the discredited infinitesimal.
public class number
{
private unlimitedString OBJvalue;
public number(int intValue)
{
OBJvalue = intValue.ToString();
}
.
.
.
}
number objNumber = new number(1);
objNumber.divideBy(3);
System.Message.Show(objNumber.Value);
The above C sharp code will have to display the string 1/3. But
suppose number has a DecimalPrecision property:
number objNumber = new number(1);
objNumber.DecimalPrecision = 10
objNumber.divideBy(3);
System.Message.Show(objNumber.Value);
now we can print "0.333333333".
A TrueValue property can return "0.333..." when DecimalPrecision is
unset.
But lets suppose that you have a calculation, with DecimalPrecision unset, that spits out a variable equal to 0.333...+
10^(-100). What does it print out now?
How about 0.333...+10^(-100)?
If we have in general a way to predict whether a given calculation is
repeating in a number base or transcendental in result, we set the
Number to the formula and do not do the formula.
"They said it couldn't be done. So, I didn't do it." - Ygor
Bastaqvetch
Mike- Hide quoted text -
- Show quoted text -
.
- References:
- Re: The "spinoza" programming language
- From: Mike
- Re: The "spinoza" programming language
- From: spinoza1111
- Re: The "spinoza" programming language
- From: Stephen Howe
- Re: The "spinoza" programming language
- From: spinoza1111
- Re: The "spinoza" programming language
- From: Mike
- Re: The "spinoza" programming language
- Prev by Date: Re: The "spinoza" programming language
- Next by Date: Re: The "spinoza" programming language
- Previous by thread: Re: The "spinoza" programming language
- Next by thread: Re: The "spinoza" programming language
- Index(es):
Relevant Pages
|