Rnd Command....?
Started by
Ben C
, Sep 20 2002 06:37 AM
6 replies to this topic
#1
Posted 20 September 2002 - 06:37 AM
Sorry for such a stupid question...
I have a program that generates some values using sine, so obviously they are very long. When I display them I only want them to 0 decimal places (I'm assuming that rnd = 'round').
I want to do something like this....
Locate 1,1,Int A
Except of course, using a command that rounds UP when necessary (Int and Intg seem to always round down).
How?
Thx
-Ben
P.S. Are Int and Intg actually different in any way?
I have a program that generates some values using sine, so obviously they are very long. When I display them I only want them to 0 decimal places (I'm assuming that rnd = 'round').
I want to do something like this....
Locate 1,1,Int A
Except of course, using a command that rounds UP when necessary (Int and Intg seem to always round down).
How?
Thx
-Ben
P.S. Are Int and Intg actually different in any way?
#2
Posted 20 September 2002 - 10:59 AM
To Rnd: - I tried this many years ago on my old good fx7700GB, may be
I forgot some detail, Rnd makes temporary rounding for displaying permanent, rounding format is taken from Fix/Sci
Example:
Fix 0
3.1415
Ans_ <-this shows 3 (temporary rounded number to display)
Norm
Ans_ <-this shows 3.1415
But he same + Rnd:
Fix 0
3.1415
Ans_ <-this shows 3 (temporary rounded number to display)
Rnd <- make temporary rounding persistent
Norm
Ans_ <-this also shows 3
To int/intg
Intg (X) = the highest integer number which is smaller or equal to X
Int (X)=Sign(X)*Abs(Intg(X))
or :
Int is the highest integer number which is smaller or equal to X, where you work only on number without sign, so
if X>=0 then Int===Intg
else (X<0)
if X is integer then Int===Intg
else (Frac (X)<>0) Int(X)=Intg(X)+1
examples:
Int(3.2)=3
Intg(3.2)=3
Int(-3.2)=-3
Intg(-3.2)=-4
I forgot some detail, Rnd makes temporary rounding for displaying permanent, rounding format is taken from Fix/Sci
Example:
Fix 0
3.1415
Ans_ <-this shows 3 (temporary rounded number to display)
Norm
Ans_ <-this shows 3.1415
But he same + Rnd:
Fix 0
3.1415
Ans_ <-this shows 3 (temporary rounded number to display)
Rnd <- make temporary rounding persistent
Norm
Ans_ <-this also shows 3
To int/intg
Intg (X) = the highest integer number which is smaller or equal to X
Int (X)=Sign(X)*Abs(Intg(X))
or :
Int is the highest integer number which is smaller or equal to X, where you work only on number without sign, so
if X>=0 then Int===Intg
else (X<0)
if X is integer then Int===Intg
else (Frac (X)<>0) Int(X)=Intg(X)+1
examples:
Int(3.2)=3
Intg(3.2)=3
Int(-3.2)=-3
Intg(-3.2)=-4
#3
Posted 20 September 2002 - 11:35 AM
Very neat and good explanation Martin, you've mentioned it better than in the manual. (sometimes I wish I write certain parts of the manual).
Anyway, what I'm going to say is just the answer for Ben so if he got confused with Martin:
You want to always round up number x for example, don't you?
Use Int(x)+sign(x)
Assuming that sign(x) gives 1 for a positive number, and -1 for a negative one.
So if the nuber is 3.2, it'll be 4, and if it's -3.2 it'll be -4.
Isn't this what you want?
Anyway, what I'm going to say is just the answer for Ben so if he got confused with Martin:
You want to always round up number x for example, don't you?
Use Int(x)+sign(x)
Assuming that sign(x) gives 1 for a positive number, and -1 for a negative one.
So if the nuber is 3.2, it'll be 4, and if it's -3.2 it'll be -4.
Isn't this what you want?
#4
Posted 20 September 2002 - 12:19 PM
and what about "integers"?You want to always round up number x for example, don't you?
Use Int(x)+sign(x)
Assuming that sign(x) gives 1 for a positive number, and -1 for a negative one.
So if the nuber is 3.2, it'll be 4, and if it's -3.2 it'll be -4.
Int(4.0000)+sign(4.0000)=5
#5
Posted 20 September 2002 - 05:14 PM
Thanks, that's great.
Although, I still wish Casio would let you do something easier, like:
Locate 1,1,Rnd 1(A)
Oh well...
-Ben
Although, I still wish Casio would let you do something easier, like:
Locate 1,1,Rnd 1(A)
Oh well...
-Ben
#6
Posted 20 September 2002 - 06:17 PM
You could do this too:
or
Locate 1,1 int (A+0.5)
or
Locate 1,1 int (A+.5)if you want to save a byte.
#7
Posted 22 September 2002 - 07:46 AM
Hmmmm...that's so crazy it might work!
Now why didn't I think of that?
Now why didn't I think of that?
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users