Re: storing values



"Nick Sutch" <nicksutch15@xxxxxxxxxxx> wrote in message
<ffhmut$sr7$1@xxxxxxxxxxxxxxxxxx>...
"us " <us@xxxxxxxxxxxxxxx> wrote in message <ffgj3l$oe9
$1@xxxxxxxxxxxxxxxxxx>...
Nick Sutch:
<SNIP FP evergreen...

Sr= sin(2.*pi.*1e3.*t)
any value which is equal to 0 displays as
number of around the order of -1e-12...

well, yes

n=5;
f=4e3;
t=1:1/f:1+((n-1)/f);
s=sin(2.*pi.*1e3.*t);
sprintf('%34.30f\n',s)

us

Thanks for the help. However, I really need to store the
values which are equal to the order of -1e-12 as 0 for
future calculations. For example: cos(0)=1 where as cos (-
6.1234e-12) does not equal 1. I appreciate the numbers are
very small and close to 0 but I was wondering if there is a
way to store the day as shorts?
Sorry, but I could not understand clearly what you want.
Unfortunately, cos(near zero) is near 1, so you should
specify what rule to follow.
If you, for example, want just a few decimals after the dot
you can issue
N=1e5;%for five decimals
s=round(N*sin(2.*pi.*1e3.*t))/N;
The plot of "s" will look similar to the original, but the
numbers will not the sin() of what is originally intended.
Hope this helps
Regards
Carlos
.



Relevant Pages

  • Re: OO versus RDB
    ... It boils down to the same thing: bunches of bytes, mostly managed by the underlying OS, with a language specific layer above. ... In C we can *store* data structures in memory (let's just call it ... I have stored multi-gigabyte multi-res images in an OODBMS and it works ...
    (comp.object)
  • Re: OO versus RDB
    ... main memory storage? ... In C we can *store* data structures in memory (let's just call it ... Suppose this CAD drawing needs to persist. ...
    (comp.object)
  • Re: BigNum -- Floating Point
    ... <snip English description of method> ... Mixed-base floating point, perhaps? ... use a big amount of space to store it. ... Then either you take the loss of precision like a man; ...
    (comp.programming)
  • Re: Why tuples use parentheses ()s instead of something else like <>s?
    ... <SNIP> ... The small store to which you can walk and where you likely know the ... about Italian culture IMHO is that it appears to understand that some ... And it is truly heart-breaking to see the beautiful countryside around ...
    (comp.lang.python)
  • Re: Quote from student, after teaching Pick
    ... you ask "why store what can be calculated?". ... We typically store Qty and Price. ... decimals places and then rounded for GST. ... cents whereas Card is exact and may even incur a further charge for using ...
    (comp.databases.pick)

Loading