realbasic-nug
[Top] [All Lists]

Re: RbScript - careful with Doubles

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: RbScript - careful with Doubles
From: Bob Delaney <delaneyrm at earthlink dot net>
Date: Thu, 29 Sep 2005 23:54:55 -0500
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <S dot 0000672091 at mail dot tempel dot org>
At 2:29 PM +0200 9/29/05, Thomas Tempelmann wrote:
RbScript still does not support Doubles, i.e. 64 bit floating point!
All it supports is the Single data type. Inside RbScript, wherever
you write "Double" it becomes a "Single" automatically.


I saw this posting about RBScript and doubles, but haven't had time to read the followups. So maybe this has all been settled. RB 2005 Release 3 does indeed not handle doubles properly. Here is a simple RB project to show this:

A pushbutton has the script:

  x=CDbl(EditFieldx.text)
  RbScript1.source=EditFieldFunc.Text
  RbScript1.Run()
  EditFieldf.text=format(f,  "#.###############")

The window has EditFieldx, EditFieldFunc, and EditFieldf. Run the RB application. Put this script in EditFieldFunc:

dim x as double
x=CDbl(Input("x:"))
print(format(exp(x), "#.###############"))

Put a 1 in EditFieldx. Click the pushbutton. You will see in EditFieldf:

2.718281828459045

This is e accurate to 16 places. So far, so good.

Now put 1.234567891234567 in EditFieldx, and click the pushbutton. You will see in EditFieldf:

3.43689346197996

That is incorrect. The value should be:

3.436893088164775

Now put 1.2345679 in EditFieldx, and click the pushbutton. You will see in EditFieldf:

3.43689346197996

which is the same bad value. So the x double value, 1.234567891234567, was converted to the float value, 1.2345679, before it was used.

This is clearly a bug.

Bob


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>