Jump to content



Photo
- - - - -

Rnd Command....?


  • Please log in to reply
6 replies to this topic

#1 Ben C

Ben C

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 20 September 2002 - 07:37 AM

Sorry for such a stupid question...:rolleyes:
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
  • PipPipPipPip
  • 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 - 11: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]
  • PipPipPipPipPipPipPip
  • 519 posts
  • Gender:Male
  • Location:Egypt, Cairo

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

Posted 20 September 2002 - 12:35 PM

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). :lol:

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
  • PipPipPipPip
  • 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 - 01: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.

and what about "integers"?
Int(4.0000)+sign(4.0000)=5 :o

#5 Ben C

Ben C

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 20 September 2002 - 06: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...:D


-Ben

#6 2072

2072

    Casio over god

  • Admin
  • PipPipPipPipPipPipPipPip
  • 1550 posts
  • Gender:Male
  • Location:Somewherebourg
  • Interests:Cinema, Programming, Music and a lot of thing...

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

Posted 20 September 2002 - 07: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
  • Pip
  • 4 posts

Posted 22 September 2002 - 08:46 AM

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

Now why didn't I think of that? :(




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users