# Rnd Command....?

6 replies to this topic

### #1 Ben C

Ben C

Newbie

• Members
• 4 posts

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?

### #2 Martin

Martin

Casio Freak

• Members
• 121 posts
• Gender:Male
• Location:Praha
• Interests:asm on cfx9850

• Calculators:
fx82l
fx7700GB
cfx9850G
TI92
fx9860G SD
Rheinmetall KEL IIc
H. W. Ebmeyer - Tarema
fx cg20

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

### #3 Mohamed

Mohamed

UCF Police

• [Legends]
• 519 posts
• Gender:Male
• Location:Egypt, Cairo

• Calculators:
AFX 2.0, PV-S660, fx-570MS

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?

### #4 Martin

Martin

Casio Freak

• Members
• 121 posts
• Gender:Male
• Location:Praha
• Interests:asm on cfx9850

• Calculators:
fx82l
fx7700GB
cfx9850G
TI92
fx9860G SD
Rheinmetall KEL IIc
H. W. Ebmeyer - Tarema
fx cg20

Posted 20 September 2002 - 12:19 PM

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 Ben C

Ben C

Newbie

• Members
• 4 posts

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

### #6 2072

2072

Casio over god

• 1563 posts
• Gender:Male
• Location:Somewherebourg
• Interests:Alternative states of consciousness, programming, making things work the best they possibly can.

• Calculators:
AFX2 ROM 1.02, CFX-9940GT+, FX-180P-Plus

Posted 20 September 2002 - 06:17 PM

You could do this too:

`Locate 1,1 int (A+0.5)`

or

`Locate 1,1 int (A+.5)`
if you want to save a byte.

### #7 Ben C

Ben C

Newbie

• Members
• 4 posts

Posted 22 September 2002 - 07:46 AM

Hmmmm...that's so crazy it might work!

Now why didn't I think of that?

#### 0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users