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
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 setting precision

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
shafei Posted - 02/07/2012 : 1:51:51 PM
Origin Ver. and Service Release (Select Help-->About Origin):8.1
Operating System:7

Hi,
I was wondering if Origin C has a command like "setprecision" in C++.
In my code in Origin C, I generate some random numbers. Instead of having a number of the form 12.3454937 I would like to generate one like 12.34. Is there a command for that?
Thanks
7   L A T E S T    R E P L I E S    (Newest First)
atashawn Posted - 03/08/2012 : 07:48:21 AM
This is quite interesting. I'd make a further research about this matter. Thank you for this input.
Penn Posted - 02/14/2012 : 03:16:23 AM
Hi,

The problem may be the calculations you have performed on the data. The data you used for calculations is with four significant digits, however, the results will not also be with four significant digits. If you want to have 4 significant digits for the results, you can use the prec function to make the results with four significant digits. In your case, maybe you can do like this:

xmax[i] = prec(xmax[i]);
ymax[i] = prec(ymax[i]);


Penn
shafei Posted - 02/14/2012 : 02:24:50 AM
Hi Penn,
I generate array of x[i]s and y[i]s randomly and use them for some other calculations. I get numbers like 3.459057 while I like one like 3.46. The "prec" command works great when I just use it and printf numbers. However, when I transfer this numbers into a worksheet, using the same code I have written, the raw numbers like 3.459057 appears there.
So let me explain the process in details:
1. I randomly generate x[i] and y[i] where I use prec command and also I have xaux[i]=x[i] and yaux[i]=y[i].
2. I do use them some calculations and some of them are stored as xmax[i] and ymax[i]. Then these values are printed out in a worksheet. Here, instead of seeing desired numbers, i.e. 3 significant digit, the numbers have 5 or 6 significant digits.
Penn Posted - 02/13/2012 : 9:40:13 PM
Hi,

I have tried the command you mentioned in Origin 8.1, however, I am afraid that I cannot reproduce the problem. If possible, you can try in other computer to see whether the problem can be reproduced.

Penn
shafei Posted - 02/13/2012 : 2:51:46 PM
I tried the code to generate some numbers with the command
x = prec(rnd() * 10, 4); and that's what I get:
7.94406
0.80123
6.32973
,etc.
What is wrong?!
I have Origin 8.1
shafei Posted - 02/07/2012 : 9:39:49 PM
Works great! Thank you very much.
Penn Posted - 02/07/2012 : 9:33:00 PM
Hi,

Please try the prec function.

Penn

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000