help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Set value to a custom significance. (no display)


From: Joris Spekreijse
Subject: RE: Set value to a custom significance. (no display)
Date: Tue, 2 Mar 2010 08:16:17 +0100

Good morning,

Thanks for the answers.
We are trying two things for our project to convert a MatLab formula into C for 
an MPU.
First thing is to see what happens when we use less bits and different fixed 
point settings for value in our formula. I am going to solve this with some old 
fashioned bit shifting.
Secondly we have strong (do not know the English term) significance. When a 
measurement device has a significance of 3 it is wrong to have an answer with a 
significance of 4 and use this result in further calculations. In that case the 
rounding trick should do his work.

Yours,
Joris

-----Original Message-----
From: John W. Eaton [mailto:address@hidden
Sent: Monday, March 01, 2010 8:09 PM
To: Judd Storrs
Cc: Joris Spekreijse; address@hidden
Subject: Re: Set value to a custom significance. (no display)

On  1-Mar-2010, Judd Storrs wrote:

| First of all, the machine native floating point is base 2, not base 10
| so this is going to be an approximation. However, something like this
| may work by removing the remainder at each step:
|
| octave:1> format long
| octave:2> a = 0.499/2
| a =  0.249500000000000
| octave:3> a = round(100*a)/100
| a =  0.250000000000000
| octave:3> b = a * 2
| b =  0.500000000000000
| octave:4> b = round(100*b)/100
| b =  0.500000000000000
|
| You could use round, ceil or floor depending on how you want rounding to work.

I recently added a chop function:

  http://hg.savannah.gnu.org/hgweb/octave/rev/27777bd27e71

But I have to ask:  Why do you think you want to do this?  What are
you trying to accomplish?

jwe



reply via email to

[Prev in Thread] Current Thread [Next in Thread]