"Many questions concerning (discrete) dynamical systems are of a number theoretic or combinatorial nature." Christian Krattenthaler

Number can be used as :
Number ( for exampleangle in turns ) can be:[1]
radix or base of a positional numeral system[14]
Notation[15]
A computer number formats ( storage forms)
brackets with exponent ( superscript) denotes how many times the series repeats[19]
Trailing zeros to the right of a decimal point, as in 12.3400, do not affect the value of a number and may be omitted if all that is of interest is its numerical value. This is true even if the zeros recur infinitely. For example, in pharmacy, trailing zeros are omitted from dose values to prevent misreading. However, trailing zeros may be useful for indicating the number of significant figures, for example in a measurement. In such a context, "simplifying" a number by removing trailing zeros would be incorrect.
The number of trailing zeros in a non-zero base-b integer n equals the exponent of the highest power of b that divides n. For example, 14000 has three trailing zeros and is therefore divisible by 1000 = 103, but not by 104. This property is useful when looking for small factors in integer factorization. Some computer architectures have a count trailing zeros operation in their instruction set for efficiently determining the number of trailing zero bits in a machine word.
First check if the ratio is in the lowest terms ( reducible)
Binary expansion can be :
Conversion between :
Using :
A fraction that is reducible can be reduced by dividing both the numerator and denominator by a common factor. It can be fully reduced to lowest terms if both are divided by their greatest common divisor
Algorithms for finding the greatest common divisor:
The Euclidean algorithm is commonly preferred because it allows one to reduce fractions with numerators and denominators too large to be easily factored
Examples:
"... we repeatedly multiply the decimal fraction by 2. If the result is greater than or equal to 1, we add a 1 to our answer. If the result is less than 1, we add a 0 to our answer." (from Virginia Tech Online CS module[35])
Algorithm:[36]
Example of conversion 0.1 decimal fraction to binary fraction :
0.1 * 2 = 0.2 -> 0 0.2 * 2 = 0.4 -> 0 0.4 * 2 = 0.8 -> 0 0.8 * 2 = 1.6 -> 1 0.6 * 2 = 1.2 -> 1 0.2 * 2 = 0.4 -> 0 0.4 * 2 = 0.8 -> 0 0.8 * 2 = 1.6 -> 1 0.6 * 2 = 1.2 -> 1 0.2 * 2 = 0.4 -> 0 0.4 * 2 = 0.8 -> 0 0.8 * 2 = 1.6 -> 1 0.6 * 2 = 1.2 -> 1 0.2 * 2 = 0.4 -> 0
Result:
Repeating fractions :[37]
0.(567) = 567/999 = 189/333 = 63/1110.(0011) = 0011 / 1111 =(in decimal) 3/15 = 1/5

Code
(Pre)periodicbinary fraction can be split into 2 fractions:
Formula for the geometric series when |r|<1 :[38]
For the infinite periodic binary fraction with empty or filled with zeros preperiodic part this formula is[39]
where :
Full formula is now:
Examples :
Conversion from decimal ratio to binary[40] usingbc – arbitrary–precision arithmetic language
bc 1.06Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.This is free software with ABSOLUTELY NO WARRANTY.For details type `warranty'. obase=23/14.00110110110110110110110110110110110110110110110110110110110110110101/5.0011001100110011001100110011001100110011001100110011001100110011001
itoa function[42]
/* itoa example http://www.cplusplus.com/reference/cstdlib/itoa/*/#include<stdio.h>#include<stdlib.h>intmain(){inti;charbuffer[33];printf("Enter a number: ");scanf("%d",&i);itoa(i,buffer,10);printf("decimal: %s\n",buffer);itoa(i,buffer,16);printf("hexadecimal: %s\n",buffer);itoa(i,buffer,2);printf("binary: %s\n",buffer);return0;}
Binary integer constant[43]
"Integer constants can be written as binary constants, consisting of a sequence of ‘0’ and ‘1’ digits, prefixed by ‘0b’ or ‘0B’. This is particularly useful in environments that operate a lot on the bit level (like microcontrollers).
The following statements are identical:
i=42;i=0x2a;i=052;i=0b101010;
The type of these constants follows the same rules as for octal or hexadecimal integer constants, so suffixes like ‘L’ or ‘UL’ can be applied."
GMP library[44]
/*C programme using gmpgcc r.c -lgmp -Wallhttp://gmplib.org/manual/Rational-Number-Functions.html#Rational-Number-Functions*/#include<stdio.h>#include<gmp.h>intmain(){// input = binary fraction as a stringchar*sbr="01001010010010100101001001010010010100101001001010010100100101001001010010100100101001010/11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111";mpq_tq;// rational number;intb=2;// base of numeral systemmpz_tn;mpz_td;mpf_tf;// init and set variablesmpq_init(q);// Initialize r and set it to 0/1.mpq_set_str(q,sbr,b);mpq_canonicalize(q);// It is the responsibility of the user to canonicalize the assigned variable before any arithmetic operations are performed on that variable.mpq_canonicalize(q);// It is the responsibility of the user to canonicalize the assigned variable before any arithmetic operations are performed on that variable.// n , dmpz_inits(n,d,NULL);mpq_get_num(n,q);mpq_get_den(d,q);//mpf_init2(f,100);// http://stackoverflow.com/questions/12804362/gmp-division-precision-or-printing-issuempf_set_q(f,q);// There is no rounding, this conversion is exact.// printgmp_printf("decimal fraction = %Zd / %Zd\ndecimal canonical form = %Qd\n",n,d,q);//gmp_printf("binary fraction = %s\n",sbr);//gmp_printf("decimal floating point number : %.30Ff\n",f);//// clear memorympq_clear(q);mpz_clear(n);mpz_clear(d);mpf_clear(f);return0;}
Output :
decimal fraction = 179622968672387565806504266 / 618970019642690137449562111 decimal canonical form = 179622968672387565806504266/618970019642690137449562111binary fraction = 01001010010010100101001001010010010100101001001010010100100101001001010010100100101001010/11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 decimal floating point number : 0.290196557138708685358212602171
Code by Claude Heiland-Allen:[45]
-- http://mathr.co.uk/blog/2014-10-13_converting_fractions_to_strings_of_digits.htmlimportData.Fixed(mod')importData.List(nub)importData.Ratio((%),denominator)importData.Numbers.Primes(primeFactors)importSystem.Environment(getArgs)dataDigits=Digits{dNegative::Bool,dInteger,dPreperiodic,dPeriodic::[Int]}derivingShowpreperiod::Digits->Intpreperiod=length.dPreperiodicperiod::Digits->Intperiod=length.dPeriodicdigitsAtBase::Int->Rational->DigitsdigitsAtBasebaserational=Digits{dNegative=rational<0,dInteger=int,dPreperiodic=pre,dPeriodic=per}whereinteger::Integerfraction::Rational(integer,fraction)=properFraction(absrational)int|integer==0=[0]|otherwise=goIntinteger[]goIntids|i==0=ds|otherwise=goInti'(fromIntegerd:ds)where(i',d)=i`divMod`baseZfactors::[Integer]factors=mapfromIntegral.nub.primeFactors$baseisPreperiodic::Rational->BoolisPreperiodicx=any(`divides`denominatorx)factorsbaseZ::IntegerbaseZ=fromIntegralbasebaseQ::RationalbaseQ=fromIntegralbase(pre,per)=goPrefractionwheregoPre::Rational->([Int],[Int])goPrex|isPreperiodicx=first(d:)(goPrex')|otherwise=([],d:goPerxx')where(d,x')=properFraction(baseQ*x)goPer::Rational->Rational->[Int]goPerx0x|x0==x=[]|otherwise=d:goPerx0x'where(d,x')=properFraction(baseQ*x)first::(a->c)->(a,b)->(c,b)firstf(a,b)=(fa,b)divides::Integer->Integer->Boolfactor`divides`number=number`mod`factor==0digitsToString::[String]->Digits->StringdigitsToStringdigitsDigits{dNegative=sign,dInteger=int,dPreperiodic=pre,dPeriodic=per}=(ifsignthen"-"else"")++dint++"."++dpre++"("++dper++")"whered=concatMap(digits!!)atBase::Int->Rational->StringatBasebaserational=digitsToStringds(digitsAtBasebaserational)whereds|base<=62=map(:[])$['0'..'9']++['A'..'Z']++['a'..'z']|otherwise=["<"++showd++">"|d<-[0..base-1]]main::IO()main=do[sbase,sfraction]<-getArgslet(snum,_:sden)=break('/'==)sfractionbase=readsbasenum=readsnumden=readsdenrational=num%denputStrLn(atBasebaserational)
# https://wiki.python.org/moin/BitManipulation# binary string to integer>>>int('00100001',2)33# conversion from binary string to hex string>>>print"0x%x"%int('11111111',2)0xff>>>print"0x%x"%int('0110110110',2)0x1b6>>>print"0x%x"%int('0010101110101100111010101101010111110101010101',2)0xaeb3ab57d55
Other methods[46]
First read:
/*gcc l.c -lm -Wall./a.outhttp://stackoverflow.com/questions/29592898/do-long-long-and-long-have-same-range-in-c-in-64-bit-machine*/#include<stdio.h>#include<math.h> // M_PI; needs -lm also#include<limits.h> // INT_MAX, http://pubs.opengroup.org/onlinepubs/009695399/basedefs/limits.h.htmlintmain(){doublelMax;lMax=log2(INT_MAX);printf("INT_MAX\t= %25d ; lMax = log2(INT_MAX)\t= %.0f\n",INT_MAX,lMax);lMax=log2(UINT_MAX);printf("UINT_MAX\t= %25u ; lMax = log2(UINT_MAX)\t= %.0f\n",UINT_MAX,lMax);lMax=log2(LONG_MAX);printf("LONG_MAX\t= %25ld ; lMax = log2(LONG_MAX)\t= %.0f\n",LONG_MAX,lMax);lMax=log2(ULONG_MAX);printf("ULONG_MAX\t= %25lu ; lMax = log2(ULONG_MAX)\t= %.0f\n",ULONG_MAX,lMax);lMax=log2(LLONG_MAX);printf("LLONG_MAX\t= %25lld ; lMax = log2(LLONG_MAX)\t= %.0f\n",LLONG_MAX,lMax);lMax=log2(ULLONG_MAX);printf("ULLONG_MAX\t= %25llu ; lMax = log2(ULLONG_MAX)\t= %.0f\n",ULLONG_MAX,lMax);return0;}
Results :
INT_MAX = 2147483647 ; lMax = log2(INT_MAX) = 31 UINT_MAX = 4294967295 ; lMax = log2(UINT_MAX) = 32 LONG_MAX = 9223372036854775807 ; lMax = log2(LONG_MAX) = 63 ULONG_MAX = 18446744073709551615 ; lMax = log2(ULONG_MAX) = 64 LLONG_MAX = 9223372036854775807 ; lMax = log2(LLONG_MAX) = 63 ULLONG_MAX = 18446744073709551615 ; lMax = log2(ULLONG_MAX) = 64
For example Wolf Jung inprogram Mandel makes a silent bounds check:[48]
// mndynamo.h by Wolf Jung (C) 2007-2014typedefunsignedlonglongintqulonglong;// mndcombi.cpp by Wolf Jung (C) 2007-2014qulonglongmndAngle::wake(intk,intr,qulonglong&n){if(k<=0||k>=r||r>64)return0LL;
If r is to big for unsigned long long int type it returns 0 to prevent integer overflow.
GMP library has arbitrary precision rationals.

"Any number with a finite decimal expansion is a rational number. " In other words : "any floating point number can be converted to a rational number."[49]
So in numerical computations one can use only integer of floating points numbers ( rational ).
InC one can use :
InMaxima CAS one can use :
(%i1) ibase;(%o1) 10(%i2) obase;(%o2) 10(%i3) ibase:2;(%o3) 2(%i4) x=1001110;(%o4) x=78
Calculation of binary numbers with as a string with replicating parts inHaskell (ghci):
-- by Claude Heiland-Allen-- http://mathr.co.uk/blog/haskell.htmlPrelude>letrepns=concat(replicatens)Prelude>putStrLn$".("++rep88"001"++"010)".(001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001010)putStrLn$".("++rep87"001"++"010001)".(001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001010001)Prelude>putStrLn$".("++rep88"001"++"0001)".(0010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010001)Prelude>putStrLn$".("++rep88"001"++"0010)".(0010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010)
InPython :
>>>bin(173)'0b10101101'>>>int('01010101111',2)687
In python one can use binary literals :[51]
pythonPython2.7.5+(default,Feb272014,19:37:08)[GCC4.8.1]onlinux2Type"help","copyright","credits"or"license"formoreinformation.>>>0b10111147

The problem is that we are exploring environments based upon irrational numbers through computer machinery which works with finite rationals ! ( Alessandro Rosa )
Expansion is non terminating and non repeating
Types:
If one wants use irrational number then should check :
The most irrational number[54] In a continued fraction all numbers are 1 = the slowest convergence of all the irrational numbers
Using Maxima CAS :
(%i10) print(float(%phi-1));(%o10).6180339887498949(%i11) rationalize(float(%phi-1));(%o11) 347922205179541/562949953421312
and :
(%i14) print(float(1/%phi));(%o14) .6180339887498948(%i15) rationalize(float(1/%phi));(%o15) 5566755282872655/9007199254740992
where denominator :
Examples
Note that in numerical computations with finite precision ( on computer) :
/*Maxima CAS batch file*/remvalue(all);kill(all);/*input = ratio, which automatically changed to lowest terms by Maxima CASoutput = string describing a type of decimal expansion---------------------------------------------------------------------------------" The rules that determine whether a fraction has recurring decimals or not are really quite simple.1. First represent the fraction in its simplest form, by dividing both numerator and denominator by common factors.2. Now, look at the denominator.3.3.1 If the prime factorization of the denominator contains only the factors 2 and 5, then the decimal fraction of that fraction will not have recurring digits. In other words : Terminating decimals represent rational numbers of the form k/(2^n*5^m)3.2 A fraction in lowest terms with a prime denominator other than 2 or 5 (i.e. coprime to 10) always produces a repeating decimal.3.2.1 If the prime factorization yields factors like 3, 7, 11 or other primes (other than 2 and 5), then that fraction will have a decimal representation that includes recurring digits.3.2.2 Moreover, if the denominator's prime factors include 2 and/or 5 in addition to other prime factors like 3, 7, etc., the decimal representation of the fraction will start with a few non-recurring decimals before the recurring part."http://blogannath.blogspot.com/2010/04/vedic-mathematics-lesson-49-recurring.htmlcheck :http://www.knowledgedoor.com/2/calculators/convert_a_ratio_of_integers.htmlwikipedia: Repeating_decimal" A fraction in lowest terms with a prime denominator other than 2 or 5 (i.e. coprime to 10) always produces a repeating decimal.The length of the repetend (period of the repeating decimal) of 1/p is equal to the order of 10 modulo p. If 10 is a primitive root modulo p, the repetend length is equal to p − 1; if not, the repetend length is a factor of p − 1. This result can be deduced from Fermat's little theorem, which states that 10p−1 = 1 (mod p)."---------------------------------------------------------------------------------------*/GiveRatioType(ratio):=block( [denominator:denom(ratio), FactorsList , Factor, Has25:false, HasAlsoOtherPrimes:false, type ], /* type of decimal expansion of the ratio of integers */ /* compute list of prime factors ofd denominator */ FactorsList:ifactors(denominator), FactorsList:map(first,FactorsList), print(denominator, FactorsList), /* check factors type : only 2 or 5 also other primes then 2 or 5 */ if (member(2,FactorsList) or member(5,FactorsList)) then Has25:true, for Factor in FactorsList do if (not member(Factor,[2,5])) then HasAlsoOtherPrimes:true, print(Has25, HasAlsoOtherPrimes), /* find type of decimal expansion */ if (not Has25 and HasAlsoOtherPrimes) then type:"periodic", if (Has25 and HasAlsoOtherPrimes) then type:"preperiodic", if (Has25 and not HasAlsoOtherPrimes) then type:"finite", return(type))$compile(all)$/* input numbers*/a:1 $b:3 $r:a/b$type : GiveRatioType(r);
In mathematic ( theory) :

"a “height function” is some real-valued function that defines the “arithmetic complexity” of a point ... " Brian Lawrence[61]
Types of the height functions defined on the set of rational numbers:
where:
"How complicated is a rational number? Its size is not a very good indicator for this. For instance, 1987985792837/1987985792836 is approximately 1, but so much more complicated than 1. We'll explain how to measure the complexity of a rational number using various notions of height. We'll then see how heights are used to prove some basic finiteness theorems in number theory. One example will be the Mordell-Weil theorem: that on any rational elliptic curve, the group of rational points is finitely generated. " Alina Bucur (UCSD): Size Doesn't Matter: Heights in Number Theory
Key words:
The probability that any random number :