Showing posts with label integer divsion. Show all posts
Showing posts with label integer divsion. Show all posts

Sunday, August 6, 2023

Integer Division with Scientific Calculators

Integer Division with Scientific Calculators



Integer Division


A popular function of European scientific and fraction-featured calculators is the integer division function (also known as Euclidean division).  Integer division between two numbers (typically positive integers) return both the quotient and the remainder.


Example:  

456 int÷ 78 returns a quotient of 5 and a remainder of 66.


Here's a way to execute integer division with various calculators.



TI-36X Pro and TI-30X Pro Math Print


Integer division can be easily accomplished by using two functions:


Quotient:  Either int(x/y) or iPart(x/y)


Remainder:  mod(x,y)


Example:   456 int÷ 78

int(456/78) = 5,  mod(456, 78) = 66



Casio fx-991EX and Casio fx-991CW


Assuming x and y are positive integers, what we do depends on whether y is prime or composite.  We will assume that MathIO mode is activated.  


If y is prime:  We can divide x ÷ y, and change the result into a mixed format.


Example:  6140 int÷ 47

47 is prime.

Key in 6140 ÷ 47.  Change the result into a mixed format.  The result is 130 30/47.


Then the quotient is 130, the remainder is 47.


If y is not prime, we will not be able to do this because the fractions are always simplified to the irreducible form.


Then we will have to use the following steps:

1.   Divide x by y.   Take note of the integer portion (you may have to change the format to mixed fraction or decimal format first).   

2.  For the remainder, execute this formula:   x - quotient * y.  


Example:  5518 int÷ 32

32 is not prime.


1.  Calculate the quotient:  5518 ÷ 32 = 172 1/4.  Note that the integer part, 172 is the quotient.

2.  Calculate the remainder:  5518 - 172 * 32 = 14.  


Then the quotient is 172, the remainder is 14.  



Hewlett Packard HP 41C/Swiss Micros DM41X


Program Code:


01  LBL ᵀ INTD

02  x<>y

03  STO Z

04  x<>y

05  ST/ Z

06  MOD

07  x<>y

08  INT

09  x<>y

10  END



Eddie


All original content copyright, © 2011-2023.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author. 


Saturday, April 17, 2021

Fun with the HP 20S (April 17, 2021 Edition)

Fun with the HP 20S (April 17, 2021 Edition)


A Quick Note - Spam Comments 

I noticed that my blog recently had a lot spam comments, especially since the beginning of this year.  Because of this I am considering turning off the ability to leave comments altogether.  If you are going to comment, please be courteous and stay on topic.  No one wants to read the same spam post about off-shore casinos, printers, or scandalous divorce inquiries.

Thank you and now, on with the post.  



Integer Division


The program calculates the quotient and remainder of the division: 


a ÷ b


Instructions:


Enter a, press [ XEQ ] ( F ), enter b.   Get the quotient, press [ R/S ], get the remainder



Program:


01 61,41,F         LBL F

02 21,2 STO 2

03 45        ÷

04 26        R/S

05 21, 1    STO 1

06 74          =

07 21,0      STO 1

08 51,45    IP

09 26          R/S

10 22,0      STO 0

11 61,45    FP

12 55        ×

13 22,1      RCL 1

14 74        =

15 51,33,0         FIX 0

16 61,44    RND   (round)

17 61,34    ALL

18 61,26    RTN



FIX 0, RND, ALL:  round the number in the display to the nearest integer


Examples:


74 ÷ 6  = 12 R 2

Keystrokes:  74, XEQ F, 6, R/S (12) R/S (2)


1576 ÷ 237 = 6 R154


Day Number


This calculates the day number given the month and the date.   A 365-day year is assumed.  


Instructions:

1.  Store month in memory register 1

2.  Store day in memory register 2

3.  Press XEQ A


Program:


01 61,41,A         LBL A

02 22,1      RCL 1

03 31        INPUT

04 2          2

05 61,42    x≤y?

06 51,41,1         GTO 1

07 33          (

08 33        (

09 22,1      RCL 1

10 75        +

11 1          1

12 34          )

13 55        ×

14 3            3

15 0          0

16 73        .

17 6          6

18 34          )

19 51,45    IP

20 65        -

21 6            6

22 3          3

23 74          =

24 21,3      STO 3

25 51,41,2         GTO 2

26 61,41,1         LBL 1

27 33          (

28 33        (

29 22,1      RCL 1

30 65        -

31 1          1

32 34      )

33 55        ×

34 6            6

35 3          3

36 45        ÷

37 2          2

38 34        )

39 51,45    IP

40 74        =

41 21,3      STO 3

42 61,41,2         LBL 2

43 75        +

44 22,2      RCL 2

45 74        =

46 21,3      STO 3

47 61,26    RTN


Examples:


February 16:  2 STO 1, 16 STO 2, XEQ A.  Result:  47

August 22:  8 STO 1, 22 STO 2, XEQ A.   Result:  234


Source:

Duffett-Smith, Peter.  Practical Astronomy With Your Calculator  2nd Ed.  Cambridge University Press: Cambridge.  1979  ISBN 0-521-28411-2


Astronomy:  Geocentric Parallax


The program calculates the quantities ρ sin θ' and ρ cos θ' where:


ρ = distance the observer is from the center of the Earth in meters

θ' = geocentric latitude in degrees


Inputs:


h = height of observer above sea level in meters

L = latitude of the observer in degrees, north is positive


Calculations:


h' = h / 6378140   (estimated radius of Earth is about 6,378 km)

u = atan(0.996647 tan L)

ρ sin θ' = 0.996647 sin u + h' sin L

ρ cos θ' = cos u + h' cos L


Program:


01 61,41,b         LBL B

02 61,23    DEG

03 33          (

04 22,1      RCL 1

05 25        TAN

06 55        ×

07 73        .

08 9          9

09 9          9

10 6            6

11 6          6

12 4          4

13 7          7

14 21,0      STO 0

15 34          )

16 51,25    ATAN

17 21,3      STO 3

18 22,2      RCL 2

19 45        ÷

20 6            6

21 3            3

22 7            7

23 8          8

24 1            1

25 4          4

26 0          0

27 74          =

28 21,4        STO 4

29 22,0      RCL 0

30 55          ×

31 22,3      RCL 1

32 23        SIN

33 75        +

34 21,1      RCL 1

35 23          SIN

36 55            ×

37 22, 4        RCL 4

38 74        =

39 26          R/S

40 22, 3        RCL 3

41 24            COS

42 75          +

43 22, 4      RCL 4

44 55        ×

45 22, 1      RCL 1

46 24          COS

47 74          =

48 61,26      RTN


Registers used:


R1 = L  (input)

R2 = h   (input)

R3 = u

R4 = h / 6378140

R0 = 0.996647


Example:


Input:

L = 45.76° N

h = 53.48 m


54.76 STO 1, 53.48 STO 2, XEQ B

Result:  

ρ sin θ' = .712859241, R/S

ρ cos θ' = .698873028


Source:

Duffett-Smith, Peter.  Practical Astronomy With Your Calculator  2nd Ed.  Cambridge University Press: Cambridge.  1979  ISBN 0-521-28411-2


Eddie

All original content copyright, © 2011-2021.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author. 

HP 20S: Acoustics Programs

HP 20S: Acoustics Programs Program A: Speed of Sound in Dry Air cs = 20.05 × √(273.15 + T°C) Code: 01: 61, 41, A: LBL A 02: ...