The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Numeric variable format problem
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

peter.cook

UK
356 Posts

Posted - 11/07/2003 :  05:43:35 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hi,

recently noticed that there is an inconsistency in the (format of) values returned from nyumeric variables.

Examples :

pete=n; n= 


pete=0.001 returns pete=1e-3
pete=0.00101 returns pete=0.00101
pete=0.002 returns pete =0.002
pete=0.00201 returns pete=0.00201
pete=0.0002 returns pete=2e-4

This is a problem as I would like to run code like the following :

[u]loop(numcol,1,%H!wks.ncols) {
loop(numrow,1,numrows) {
%T=%(%H,numcol,numrow);
%(NewSheet,numcol,numrow)=%T;
};
};

for simplicity.

The issue is copying from and to mixed format worksheets ('numeric and text' and 'text' data).
Any help appreciated.

Cheers,

Pete

greg

USA
1380 Posts

Posted - 11/07/2003 :  10:20:24 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
There are two parts here:
Your first examples only demonstrate that Origin has options to auto-display values above or below specified magnitudes in standard or scientific notation. In the examples, all numbers less than or equal to .001 display in scientific notation - which means you are using the default Tools : Options : [Numeric Format] : "Lower Threshold Power" of -3. In all your cases, the real values and the displayed values are mathematically equivalent. There could be a case where the real value differs mathematically from the displayed value. For example, enter 0.999999999 into a cell and (by the defaults controlling the display format) you will see 1 : an 'error' of .000000001.

There can, therefore be a problem if you put the display form of numeric data into a text column : you will lose some precision.

I think an older version of Origin used to exhibit this problem when using %(worksheet,column,row) notation, but it was fixed, and - in addition - we added the cell(row,column) notation which can do text or numeric.

So you should be aware of differences in script handling of data formats, and you should code to handle those differences. In a worst case scenario - mixed text and numbers - you might have to do some creative programming, such as:

loop(numrow,1,numrows) {
%T=%(%H,numcol,numrow);
if($(%T)==0/0) NewSheet!cell(numrow,numcol)$= %T;
else NewSheet!cell(numrow,numcol)=%T;
};

Note that the %(worksheet,column,row) notation does not allow for string assignment, so I used the worksheet!cell() function which can do either text or numeric. Also - a warning - I've forgotten which service release of which version introduced the cell() function, but it was initially defined as cell(numcol,numrow).

Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000