RB 5.1 windows : Is it a joke ? 
Author Message
 RB 5.1 windows : Is it a joke ?

Hi,

I am evaluating RB 5.1 .
evrything worked fine until i began to get a bit more deeply into it.
I am trying to code a class for complex numbers and i get strange errors
i.e
    //local definition
    dim n as single
    n=-1.3
   results in -1,299999952316284 when watching in de{*filter*} .

 i've checked that no other variables with the same name exists.
even worse with doubles the results are completely absurds.

any hints apart from subscribing my computer to A.anonymous group.

TIA

Eric



Sun, 23 Oct 2005 00:24:47 GMT  
 RB 5.1 windows : Is it a joke ?

Quote:

> I am evaluating RB 5.1 .
> evrything worked fine until i began to get a bit more deeply into it.
> I am trying to code a class for complex numbers and i get strange errors
> i.e
>     //local definition
>     dim n as single
>     n=-1.3
>    results in -1,299999952316284 when watching in de{*filter*} .

Well, that's the value as it really is internally.  You can't represent
1.3 (or -1.3) exactly in binary; with a Double you would get closer, but
no amount of precision can represent it exactly.

Quote:
>  i've checked that no other variables with the same name exists.
> even worse with doubles the results are completely absurds.

How so?

Cheers,
- Joe

,------------------------------------------------------------------.
|    Joseph J. Strout         Check out the Mac Web Directory:     |

`------------------------------------------------------------------'



Sun, 23 Oct 2005 00:28:40 GMT  
 RB 5.1 windows : Is it a joke ?

Quote:
> > I am evaluating RB 5.1 .
> > evrything worked fine until i began to get a bit more deeply into it.
> > I am trying to code a class for complex numbers and i get strange errors
> > i.e
> >     //local definition
> >     dim n as single
> >     n=-1.3
> >    results in -1,299999952316284 when watching in de{*filter*} .

?????? I mean, if you build a calculator and try 1+1 whatever the
vartype is, you expect the result to be 2 not 1,99999blahblah.
ask vb,c,matcad  or even director how much is 2+2. I understand your
statement
but try to give excel 1+1 it wont tell you that it should be between
1,9999 and 2,0001. I mean if i ask back the result I get it biaised it is
not
only a de{*filter*} representation of the number.

Quote:

> >  i've checked that no other variables with the same name exists.
> > even worse with doubles the results are completely absurds.

> How so?

say n=-1,3 internal result (i.e de{*filter*} says) n=-9,blahblah E-65


Sun, 23 Oct 2005 01:44:26 GMT  
 RB 5.1 windows : Is it a joke ?

Problem seems to be elsewhere in my windows XP box. Mathcad crashed
my system and I can't even reread my rb file. So I should probably be the
one to
subscribe to the AA group. :)

Thanks

Eric



Sun, 23 Oct 2005 02:03:45 GMT  
 RB 5.1 windows : Is it a joke ?

Quote:

> ?????? I mean, if you build a calculator and try 1+1 whatever the vartype
> is, you expect the result to be 2 not 1,99999blahblah. ask vb,c,matcad  or
> even director how much is 2+2. I understand your statement but try to give
> excel 1+1 it wont tell you that it should be between 1,9999 and 2,0001. I
> mean if i ask back the result I get it biaised it is not only a de{*filter*}
> representation of the number.

Excel knows about this and it rounds.

PS: Please add your name to your newsreader settings.

Mfg
Christian

--
Four thousand functions in one REALbasic plug-in. The MBS Plugin.

< http://www.*-*-*.com/ ;



Sun, 23 Oct 2005 01:42:46 GMT  
 RB 5.1 windows : Is it a joke ?

Quote:

> > >    results in -1,299999952316284 when watching in de{*filter*} .

> ?????? I mean, if you build a calculator and try 1+1 whatever the
> vartype is, you expect the result to be 2 not 1,99999blahblah.

That's what you'd get here too.  2 (as well as 1) can be represented
exactly in binary.  1.3 can't.

For that matter, if you build a calculator, the user will probably not
be viewing the result in the de{*filter*}.  If you display the result with
str() or Format(), you'll find you get 1.3 as you would expect.  That's
rounding to a reasonable number of digits.  But the de{*filter*} shows you
the full content of the variable.  This is a Good Thing, because some
people may need to know exactly what their variable contains.

Quote:
> > >  i've checked that no other variables with the same name exists.
> > > even worse with doubles the results are completely absurds.

> > How so?

> say n=-1,3 internal result (i.e de{*filter*} says) n=-9,blahblah E-65

Well now THAT looks like a bug.  Please report it with the feedback form.

Thanks,
- Joe

,------------------------------------------------------------------.
|    Joseph J. Strout         Check out the Mac Web Directory:     |

`------------------------------------------------------------------'



Sun, 23 Oct 2005 03:19:33 GMT  
 RB 5.1 windows : Is it a joke ?

Quote:
> > I am evaluating RB 5.1 .
> > evrything worked fine until i began to get a bit more deeply into it.
> > I am trying to code a class for complex numbers and i get strange errors
> > i.e
> >     //local definition
> >     dim n as single
> >     n=-1.3
> >    results in -1,299999952316284 when watching in de{*filter*} .

> Well, that's the value as it really is internally.  You can't represent
> 1.3 (or -1.3) exactly in binary; with a Double you would get closer, but
> no amount of precision can represent it exactly.

This statement is shocking me (but maybe It should not?).
Depending on the way you code (i.e. implement) your numbers you can
represent anything correctly (i.e. you can represent anything
correctly in binary).
1.3 is 13 multiplied by 10 to the power of -1.
The mantisse is 13 and the exponent is -1 (if my "forgotten
vocabulary" is correct).
So you can represent 1.3 (and -1.3) exactly in binary.

Has my (maths, physics and computer sciences) high-school diploma
expired? :-)

A+
Pascal.

"Re: RB 5.1 windows : Is it a joke ?" -> Yes it is I think...



Sun, 23 Oct 2005 16:06:21 GMT  
 RB 5.1 windows : Is it a joke ?

Quote:

> > Well, that's the value as it really is internally.  You can't represent
> > 1.3 (or -1.3) exactly in binary; with a Double you would get closer, but
> > no amount of precision can represent it exactly.

> This statement is shocking me (but maybe It should not?).

It should not.

Quote:
> Depending on the way you code (i.e. implement) your numbers you can
> represent anything correctly (i.e. you can represent anything
> correctly in binary).

You're talking about something different.  I'm talking about the
standard numeric representation used natively by all computers, defined
by IEEE for decades now.

Yes, there are other ways to represent numbers digitally -- BCD is a
good one.  There are RB plug-ins that use these other ways, or you could
write it yourself in RB.  But when you declare a variable as "single" or
"double" you get the standard native numeric datatype -- the same one
used by the FPU unit of the CPU.

Quote:
> "Re: RB 5.1 windows : Is it a joke ?" -> Yes it is I think...

No, it is not.

Cheers,
- Joe

,------------------------------------------------------------------.
|    Joseph J. Strout         Check out the Mac Web Directory:     |

`------------------------------------------------------------------'



Sun, 23 Oct 2005 22:39:54 GMT  
 RB 5.1 windows : Is it a joke ?
Hi Pascal,

Quote:
> 1.3 is 13 multiplied by 10 to the power of -1.
> The mantisse is 13 and the exponent is -1 (if my "forgotten
> vocabulary" is correct).
> So you can represent 1.3 (and -1.3) exactly in binary.

> Has my (maths, physics and computer sciences) high-school diploma
> expired? :-)

> A+
> Pascal.

Yes, it has. You cannot represent 0.1 in binary either - your method just
"moved" the problem around like "5 is not an even number" ... "but I can
represent 5 as 4 + 10^0 and both 4 and 10 are even so 5 must be even"  ;-)

Doesn't work mate.

Btw I'm a biologist, not a mathematician or a computer programmer. I too had
an A+ in Maths (in Germany), and I'm quite shocked at the standards in Maths
here in New Zealand (people who got an A+ and who can't even solve quadratic
equations properly).

Quote:
> This statement is shocking me (but maybe It should not?).

And yes, there are ways to do it exactly - you might be shocked to learn
that a cheap $5 pocket calculator beats the pants of your $1,000 computer
when it comes to maths ...  ;-)

... but not by using the standard "single, double" - you need to encode your
own way of dealing with numbers on the basis of 10 (as opposed to the
computers way of dealing with numbers on the basis of 2)

Markus

P.S. System: 17in iMac, 512 MB, MacOS X 10.2.4, RB5.1fc5

--

Dr. Markus Winter
Tel: 0064 (0)9 373 7599 (wait for message then type extension) 83960

               \\|//
               (o o)
-. .-.   .-oOOo~(_)~oOOo-.   .-. .-.   .-. .-.   .-. .-.   .-. .-.   .-.
||X|||\ /|||X|||\ /|||X|||\ /|||X|||\ /|||X|||\ /|||X|||\ /|||X|||\/|||X\
|/ \|||X|||/ \|||X|||/ \|||X|||/ \|||X|||/ \|||X|||/ \|||X|||/ \|||X|||/
'   `-' `-'   `-' `-'   `-' `-'   `-' `-'   `-' `-'   `-' `-'   `-' `-'



Mon, 24 Oct 2005 05:16:02 GMT  
 
 [ 11 post ] 

 Relevant Pages 

1. Printing Problems on Window with RB 5.1 for both the mac and windows

2. From Demo to Full RB 5.1

3. RB 5.1 Drag and Drop Garbage

4. RB 5.1 and EditableMovies

5. A custom built DLL crashes labview 5.1 in windows 2000 but worked fine in windows 98

6. 814078: Security Update (Microsoft Jscript version 5.1, Windows 98 and Windows N

7. Strange problem with REALBasic 5.1 and window resizing

8. Printing Issues in Windows 2000 and Netware 5.1

9. Clipper 5.3b/Blinker 5.1 and Windows

10. Clipper 5.3b - Blinker 5.1 - Windows NT

11. exponential window in Labview 5.1

 

 
Powered by phpBB® Forum Software