Difference between revisions of "TI-BASIC:Decimal To Fraction2"

From Learn @ Cemetech
Jump to navigationJump to search
(Initial automated import)
 
(Automated @@ correction)
 
Line 2: Line 2:
  
 
{{Template:TI-BASIC:Routine
 
{{Template:TI-BASIC:Routine
|picture=@@
+
|picture=
 
|summary=Converts a decimal into a fraction
 
|summary=Converts a decimal into a fraction
 
|input=''Ans'' - Decimal input  
 
|input=''Ans'' - Decimal input  
Line 9: Line 9:
 
|compatibility=TI-83/84/+/SE
 
|compatibility=TI-83/84/+/SE
 
|author=12Me21
 
|author=12Me21
|authors=@@
+
|authors=
|url=@@
+
|url=
|download=@@
+
|download=
 
}}
 
}}
  

Latest revision as of 22:09, 24 February 2016



Routine Summary

Converts a decimal into a fraction

Inputs

Ans - Decimal input

Outputs

Ans - Numerator (1), Denominator (2)

Variables Used

A, B, Ans

Calculator Compatibility

TI-83/84/+/SE Author

12Me21 Download

No download provided.

:Ans→A:1→B
:While fPart(A
:10A→A:10B→B
:End
:{A,B}/gcd(abs(A),B

It starts by setting up a fraction with the input as the numerator and 1 as the denominator. After that, it multiplies both by 10 until the numerator is an integer, and then simplifies the fraction.

Error Conditions

  • ERR:DATA TYPE is thrown if Ans is an imaginary or complex number
  • ERR:DOMAIN is thrown if Ans has more than 11 digits after the decimal.

Related Routines