IEEE-754 Float 64 library.

FL64 is an number analytics, and error correction library.


Project maintained by Recoskie Hosted on GitHub Pages — Theme by mattgraham

Indexed contents.

Number in Parts: LinkBasic functions.
Adding parts back together: Link
Manipulating parts: Link
Creating a number in Parts: Link
Irrational numbers: LinkAnalyzing Numbers, and how it works.
The secret structure to all numbers (No such thing as random numbers): Link
Periodic Recurring/number patterns: Link
Fraction Data type: LinkError correction.
Error Correction: Link
Binary translation operations: LinkBinary, and bitwise operations.
Direct Binary bitwise operations: Link
Vector and Array operation: Link


Number in Parts.

1. Numbers can be split into parts.
2. Numbers have a length, for numbers of parts split into.

Using the split method.

var pi = 3.1415; pi = pi.split(); console.log(pi); pi = pi.split(); console.log(pi);

As you can see the more we split the value. The closer we get to 0. You can also view each part by calling the toString method.

var pi = 3.1415; pi = pi.split(); console.log(pi.toString()); pi = pi.split(); console.log(pi.toString());

Each "a" is a part taken out of the number.
Each "b" is the scale used.

Generally all b=1 is as high as it goes going to the next part in the number.

If b is set 2, or -2. Then we are going half to the next value. Does not matter which direction -/+.

If b is 3 then it is a third in scale to the next part across the number, and so on.

The method reValue displays the next part after each split.

var pi = 3.1415; console.log(pi.reValue()); pi = pi.split(); console.log(pi.reValue()); pi = pi.split(); console.log(pi.toString());

Each reValue is what each next "a" part is at maximum value that can be taken out of the number in the next split.

You can change the A, and B part to what ever you like per split.

Also the larger you set "b", then the bigger "a" becomes in the next part, because of the scale size.

var pi = 3.1415; pi = pi.split(7,9); pi = pi.split(3,5); console.log(pi.toString());

In this example we split by different values per part. In the next example we will continue to split till value is 0.

var pi = 3.1415; pi = pi.split(7,9); pi = pi.split(3,5); while( pi > 0 ) { pi = pi.split(); } console.log(pi.toString());

Instead of using split in a loop till 0 when you want to split a number into all remaining parts. You are best off using the method splitAll.

var pi = 3.1415; pi = pi.split(7,9); pi = pi.split(3,5); pi = pi.splitAll(); console.log(pi.toString());

Adding parts back together.

var pi = 3.1415; pi = pi.splitAll(); var fract = pi.calcF(); var Number = pi.calc(); console.log(pi.toString()); console.log(fract.toString()); console.log(Number.toString());

Methods calcF, and calc add the parts together.

calcF adds start to End parts to a fraction.

calcF, and calc can also add from start to end parts.

In the next example we will start at part 2, and add up parts till part 5.

var pi = 3.1415; pi = pi.splitAll(); var fract = pi.calcF(2, 5); var Number = pi.calc(2, 5); console.log(pi.toString()); console.log(fract.toString()); console.log(Number.toString());

You can also use the length to stop at one part less before the end. This is useful for rounding off the part at the end of a number such as filtering out error.

var pi = 3.1415; pi = pi.splitAll(); var fract = pi.calcF(0, pi.length - 2); var Number = pi.calc(0, pi.length - 2); console.log(pi.toString()); console.log(fract.toString()); console.log(Number.toString());

Each time you split a number the length gets bigger by one. The length is the number of parts a number has been split into. When adding parts together the last part is -1 of length. In the above example we subtract the length by 2 which is one part less before the end of the number. When we add the parts into a fraction or number we are adding one part less before the end.

Manipulating parts

The parts a number is split into can also be manipulated.

var pi = 3.1415; pi = pi.splitAll(); console.log(pi.toString()); pi = pi.remove(4); pi = pi.splitAll(); console.log(pi.toString());

In this example part 4 is removed.

Which is a=8, b=1.

As you can see part 4 is gone when we display the set after the remove operation.

Pay attention to where the end with 0 remaining value is. To see the separation between before, and after.

Because we changed the parts the value is no longer 0, so method splitAll is used to split to all remaining parts before displaying the result again.

var pi = 3.1415; pi = pi.splitAll(); console.log(pi.toString()); pi = pi.setA(4, 3); pi = pi.setB(4, 4); pi = pi.splitAll(); console.log(pi.toString());

Instead of removing the 4th part we modify the 4th part to be a=3, b=4.

Methods setA, and setB Use the first value for which part then the second value for which number you wish to set it to.

Transforming parts.

Lets say you want to modify a whole bunch of parts at one time.

var val = 1.3922111911773327; function A(x) { return(x); } function B(x) { return(x); } val = val.splitAll(); console.log(val.toString()); val = val.Trans(0,A,B); console.log(val.toString());

This is one of the most useful operations you will be using.

The first set of parts are the arraignment of parts that are at max value per part using method splitAll.

The second set is the output from the transform method. The transform method terminates if a value is out of range -/+, or if you hit 0.

The transform method needs two functions as inputs. Both functions take a single input which is part number.

The input to the functions A, and B is 1,2,3,4,5,6 by part number.

It is up to you what you want to return as a value from the two functions. In the example I return the value x which goes 1,2,3,4,5,6 and so on by part number.

Each 1,2,3,4,5,6 can even be used as a array index if you wish to transform by specific values, or you can calculate each value per value.

Some modifications you can make to see what happens is changing "val = val.Trans(0,A,B);" to "val = val.Trans(1,A,B);".

This changes the start position in the parts you wish to transform. Also take note that the transform method will terminate sooner, because the parts will most likely be out of range -/+.

You can change the starting position to what ever you like to see the effect for your self. Set it 3, or even 5.

Creating A number in parts.

In order to create a number you start with a value that is NaN. Which stands for Not a Number.

You then can do all manipulation operations, or split by "a", and "b".

In order to get a fraction, or number back you add the parts back together using methods calc, or calcF

var val = NaN; val = val.split(1,1); val = val.split(2,1); val = val.split(2,1); val = val.split(2,1); val = val.split(2,1); val = val.split(2,1); val = val.split(2,1); val = val.split(2,1); val = val.split(2,1); val = val.split(2,1); val = val.calc(); console.log(val.toString());

We can create the square root of 2 using this split sequence.

You can split into any number you like per part.

Now lets say you wish to continue this splitting sequence to the end. Instead of doing a bunch of split operations. You are best to use the transform operation.

var val = NaN; function A(x) { return(2); } function B(x) { return(1); } val = val.split(1,1); val = val.Trans(1,A,B); val = val.calc(); console.log(val.toString());

In this example we split the first part as a=1, b=1.

Then we transform the rest of the parts as a=2, b=1 using function A and B.

Then we add it together with the calc Method.

This makes the square root of 2.

You can change this, however you like. You can create any number you like using this.

Irrational Numbers.

An irrational number is a value that can never be solved to it's exact value.

An irrational number is a number like this: 1.101001000100001.

Which we can clearly see what the pattern is. As it is 1 followed by one more zero per place value.

Because of this pattern. We can make the number bigger forever without any repeating digits.

var val = NaN; function A(x) { return( Math.pow( 10, x + 1 ) + 1 ); } function B(x) { return( -Math.pow( 10, x + 1 ) ); } val = val.split(1,1); val = val.split(10,-10); val = val.Trans(2, A, B); val = val.calc(0,9); console.log(val);

In the above code we calculate the number by adding parts together. In which each A to B is as follows.

Pattern.
AB
11
10-10
101-100
1001-1000
10001-10000
100001-100000
1000001-1000000
10000001-10000000
100000001-100000000


Each A part is 10 times bigger plus 1, and each B part 10 times bigger, for scale.

You can split irrational numbers into smaller parts. You can also add together irrational numbers using per smaller parts.

However, the digits in the number will never repeat. For, example PI to a billion digits: Link.

Irrational numbers can also be created when you measure something that gets a tiny bit bigger in ratio to another distance.

The most basic example is a circle. The circles outside distance gets slightly bigger than the distance across per bigger circle.

This means you are going to get a different number each time you make the circle bigger. The pattern continues farther down the decimal place per bigger circle. AS the two lengths change in ratio as you go bigger down the decimal place.

var val = NaN; function A(x) { return( 6 ); } function B(x) { return( 1 + (x * 4) + (x * x * 4) ); } val = val.split(3,1); val = val.Trans(1,A,B); val = val.calc(); console.log(val.toString());

The above example calculates the number PI per additional part.

This is much different than the physical measurement. As we add per part together to create the number.

The golden ratio.

The golden ratio is a very fascinating irrational number as each part is as small as it possibly can be per part.

All parts are exactly a=1, b=1. It is considered the most irrational number because of this.

var val = NaN; function A(x) { return(1); } function B(x) { return(1); } val = val.Trans(0,A,B); val = val.calc(); console.log(val.toString());

Square roots.

Every square root is related to the golden ratio. Here is a table of every square root.

√1_√2_√3_√4_√5_√6_√7_√8_√9_√10_√11_√12_√13_√14_√15_√16_√17_√18_√19_√20_√21_√22_√23_√24
AB_AB_AB_AB_AB_AB_AB_AB_AB_AB_AB_AB_AB_AB_AB_AB_AB_AB_AB_AB_AB_AB_AB_AB
10_11_12_20_21_22_23_24_30_31_32_33_34_35_36_40_41_42_43_44_45_46_47_48
00_21_22_00_41_42_43_44_00_61_62_63_64_65_66_00_81_82_83_84_85_86_87_88
00_21_22_00_41_42_43_44_00_61_62_63_64_65_66_00_81_82_83_84_85_86_87_88
00_21_22_00_41_42_43_44_00_61_62_63_64_65_66_00_81_82_83_84_85_86_87_88
00_21_22_00_41_42_43_44_00_61_62_63_64_65_66_00_81_82_83_84_85_86_87_88
00_21_22_00_41_42_43_44_00_61_62_63_64_65_66_00_81_82_83_84_85_86_87_88
00_21_22_00_41_42_43_44_00_61_62_63_64_65_66_00_81_82_83_84_85_86_87_88
00_21_22_00_41_42_43_44_00_61_62_63_64_65_66_00_81_82_83_84_85_86_87_88
00_21_22_00_41_42_43_44_00_61_62_63_64_65_66_00_81_82_83_84_85_86_87_88
00_21_22_00_41_42_43_44_00_61_62_63_64_65_66_00_71_82_83_84_85_86_87_88


var val = NaN; function A(x) { return(8); } function B(x) { return(7); } val = val.split(4,7); val = val.Trans(1,A,B); val = val.calc(); console.log(val.toString());

In this example we calculate the square root of 23.

You can also use square root to calculate a number in which All A and B parts are the same using:

(A÷2) + √(A2÷4+B)

Replace A and B with what you want each part to be.

We then can calculate the golden ratio as (1÷2) + √(12÷4+1).

We go 12÷4 = 0.25 then add the + 1 = 1.25 is the square root, and 1÷2 is 0.5 which is added to the square root.

Which makes the square root of 0.5+√1.25=1.618033988749895.

The example code below uses what you set A and B then uses the calculation to generate the value. The calculated value is then split apart by what you set, A and B equally till 0 remainder. Which proves the calculation.

var a = 71, b = -11; var v = a/2 + Math.sqrt(a*a/4 + b); console.log( "Calculated value = " + v + "" ); while( v != 0 ){ v=v.split(a,b); } console.log( "Value split in A by B\r\n" + v.toString() );

Set a = 71, b = -11; to whatever you like, and it will calculate a different number using the math calculation and should always split apart equally in A by B.

There is a method in which you square the remaining part to find the best A to B part.

Doing this allows you to solve the patterns to all irrational numbers no matter how they are generated per part.

This includes sine, cosine, tangent, x to y root, logarithms, and even PI.

Even numbers you create per digit such as 1.101001000100001. Which the pattern is obvious.

The Natural logarithm.

Natural log.
AB
21
11
22
33
44
55
66
77
88
99


var val = NaN; function A(x) { return( x ); } function B(x) { return( x ); } val = val.split(2,1); val = val.Trans(1,A,B); val = val.calc(); console.log(val.toString());

The natural log is another good example. As you can see this is similar to that of our square roots, and the golden ratio. With one slight difference. Each part is +1 from before.

Each number relates to each other. Think of this as the golden ratio to the square, and then to natural log, and PI as a spiral stir case squared.



If you really do understand, and really work out the A to B part square ratio. Then you can line up any number to it's pattern.

Then you can use the quantum matrix to convert all parts into the exact number pattern Link.

If you are interested in the geometric space of all number patterns. Then you can go here Link.



At the smallest scale (how it works).

The Golden ratio is the smallest distance possible per part across a number. It can be added together by adding previous number to the next number creating a set called the Fibonacci sequence.



Fibonacci = 0,1,1,2,3,5,8,13,21,34,55,89,144,233,377

Each Fibonacci number divided by a prior Fibonacci number forums the golden ratio 377÷233=1.618025 per a=1, b=1 part. In perfect equilibrium.

If you pick 8 and do 8÷5=1.6. You will find 1.6 splits in A=1, and B=1 the same number of times as it took to add to the Fibonacci number 8.

This is because each prior value divides one time evenly, and as we add the previous value to the next value, we end up with a remainder that divides evenly one time again that includes the previous remainder. If we start with 0, 1 and multiply by 2 as we add the next value, we would end up with a value that divides evenly twice per part.

If we wish to split the fraction 8÷5 going backwards. The value for each A-part is how many times 5 divides into 8. It divides once, so the value for A-part is 1. We are left with 8-5=3 going backwards.

We divide the remainder 3 by the value we wish to use for B-part. In this example we will choose not to scale the remainder smaller going into next part so we will keep B=1.

We take our remainder and divide it by the number we previously divided by which was 5. We go 5÷3. We end up with it dividing once, making A=1 with a remainder of 2. We can do this same process two more times going backwards before we have 0 remaining.

Splitting a number into parts is the same process. The number before the decimal point is each A-part. The value 1.6 is A=1 so we take the part away leaving 0.6 remainder.

We divide the remaining value 0.6 by B-part scale. In this example we will leave B=1 (no Scaling).

We divide 0.6 into 1 to find the next part. We go 1÷0.6=1.6666666666666. We do the Same A to B process till 0.

Both ways end up with the same results. When we divide the number into 1 we are basically asking how many times does the value go evenly the same as we did with the fraction till zero going backwards. This gives us an way to add the value back into a fraction.

By adding the previous number to the next number, starting with 0, 1, and multiplying by each A-part creates the numerator. Doing the same thing, starting with 1, 0 with B-part creates the denominator. Which adds to the fraction. We can get the information for each A=? part by dividing the number into 1 to find the next evenly dividable value per part.

We only include B-part when sizing up the parts into a calculation to calculate an number per part. To learn how to use the B-part to line up numbers, see the previous section on the square calculation: Link.

All fractions and numbers can be split into parts, and then added back to their smallest fraction this way. As the number of times A-part goes into numerator will always match even if the fraction is larger than it should be. As 30 by 20 is still the same as 3 by 2 as it divides the same number of times till 0 even if both numbers are larger. Taking the number of times the value divided evenly till zero and adding them back into a numerator, and denominator forums the smallest fraction 3 by 2 even if we used 30 by 20.

The Fibonacci sequence relates to adding per smaller part at the smallest scale without multiplying by an bigger value than A=1. The golden ratio is a direct 1:1 relation to the whole structure.

The golden ratio is also a perfect rectangle called the golden rectangle.

You can also create the golden rectangle with the Fibonacci sequence by using square tiles of each length of each Fibonacci number and placing them in front of each other as in the diagram.

By measuring the bottom, and measuring the right side. Then dividing the two lengths. You get the golden ratio per part as well per square tile you added. The bigger the rectangle the more accurate the number is.

The same rule applies to a circles outside distance divided by its distance across, which is why the number PI is a construction of parts that go on forever per bigger circle and is the very nature of what irrational numbers are. The golden ratio is the only number in which each part is exactly as small as can be per part as all A=1, B=1.

The Fibonacci sequence and golden ratio is a spiral in nature when you connect the values together in the placement of its shape per square tile part, as seen in the diagram.

All numbers have a place along the spiral. Rational numbers are a finite point. While irrational numbers go forever along the spiral. There is also no such thing as a random number.

You can create a geometric space of all numbers if you like. You can also give them meaning to the natural world, or just have them represent them selves.

It also exists in the formation of galaxies. Spanning from 0 as 0,1,1,2,3,5,8,13,21,34,55,89,144,233,377.



You can also calculate the golden ratio as the pentagram.



The golden ratio is the most irrational number as each part across the number per smaller part is exactly 1 away per A=1, and B=1.

You may also find the following article fun as it describes different numbers and their relationship to reality. Nature numbers are the keys to the cosmos.

You may also like The purpose of life and golden ratio explained.

Rational Vs Irrational.

In theory, if we could store an infinite number of digits.

All rational numbers can be split to 0 parts remain across the number. Then added back to smallest fraction using calcF.

Irrational numbers can be split forever into smaller parts, and will never hit 0.

Computers have a limit for the number of digits we can store. So making the determination between the Rational/Irrational is hard. However, it is possible.

We can say a number is irrational if the final split before 0 is at the end of the accuracy of a floating point number in the computer.

The other method is calculating A to B ratio square. Finding both A and B. Then solving the number pattern with the quantum matrix: Link

It is possible to determine one from the other even with limited digits. However, it requires you to solve the squaring of B to A parts. Then using the matrix to solve the pattern.

Periodic number patterns.

Periodic number patterns happen when you divide a number that does not divide evenly out of the number of digits you are using to count before you carry to the next column.

Many people use to think that the number PI would eventually repeat. When a number repeats, this means it can be represented as a "finite value = single fraction".

The next place value is 10 after 9. When we divide any number by 9, it will create a remainder that is the same across the number forever.

1÷90.111111111111111
2÷90.222222222222222
3÷90.333333333333333
4÷90.444444444444444
5÷90.555555555555555
6÷90.666666666666666
7÷90.777777777777777
8÷90.888888888888888


You can make the fractions smaller. You can change 3÷9 to 1÷3. Which is the same fraction.

Anything divided by the last digit creates a indivisible remainder that is the same across the number forever.

The next place value is 100, so 100-1=99. Any two digits divided by 99 will repeat forever across the number as it is indivisible.

23÷99=0.23232323232323

The next place value is 100*10=1000, so 1000-1 is 999. Thus any three digits divided by 999 will be indivisible.

719÷999=0.719719719719719

You can make any number you like that is indivisible. Thus creates a number pattern using division. That is recurring, and periodic.

var val = 3 / 9; console.log(val);

In this example you can try it out your self. You can also change the 3÷9 (3 / 9) with every value you come up with that is indivisible.

The pattern does not have to start right away as we can offset the pattern by adding a starting value. Say we want to do a pattern of 73. We need 73÷99. Adding an zero to 99 will offset the pattern by one place value 73÷990 = 0.073737373. Adding another zero will offset it by another place value 73÷9900 = 0.0073737373 and so on. Using 9900 we can set two place values after the decimal point to whatever we like. Using the calculation (73+r*9900)÷9900 in which r is our chosen digits. We multiply 9900 by 97.16 as our chosen digits 9900x97.16=961884 we then add our patten 73 making 961884 + 73 = 961957. Lastly 961957÷9900 = 97.16737373737373.

Periodic number patterns relate to the number of digits you are using to display your value in divisible place values.

var val = 3 / 9; console.log(val.toString(3));

In this example the fraction 3÷9 works out as 0.1. This is, because we are dividing the number up in place values of 3. Which is what toString(3) does.

This is called changing the number base from base 10 to base 3. Instead of each place value being in 10 per place value. It is in place values of 3.

This means we have three digits instead of ten. Thus in three digits 1÷3 is perfectly dividable as one third = 0.1.

Changing the number of digits we use in a number system changes what is divisible between the number of digits. In base three we count till 2 and carry to 10 which is 3 in value. This means the last value before the next place value is 2 and anything divided by 2 will not divide. Also anything divided by 22, or 222 in base three will not divide and will repeat across the number forever.



Use the left and right arrows to change the number base. Use the up and down arrows to navigate through all number pattern combinations. You might have to zoom in if you are on a small display, or cell phone to use it.

For example half of something can never be dividable out of thirds per place value. However half of ten digits is evenly 5, so a half out of ten units is 0.5.

So it does not matter what the number of digits you use are. You get the same problem. You end up with 50% divisible numbers, and 50% indivisible periodic numbers. Even if you used base 60 numbers.

But, don't worry so much about divisibility of place values in a number system. Since you can split these types of numbers into parts. Then add the parts together into smallest fraction with calcF.

var val = 3 / 9; val = val.splitAll(); val = val.calcF(); console.log(val.toString());

This way you do not have to worry about these messed up types of numbers.

Using this knowledge we can use division characteristics to achieve some interesting algorithms.

1. Such as algorithms that find, and translate recurring (periodic) patterns quickly in data with a single calculation.

2. Generating fun random looking sequences that repeat infinitely periodically.

Creating a division pattern.

To create a new division pattern you use the Pattern data type.

var pat = new Pattern("31415",10); console.log(pat); var fract = pat.getFract(); console.log(fract.toString());

We chose the pattern 31415, using out of ten digits. Thus we use the method getFract to get the smallest fraction.

We can get more complex than this if we like.

var pat = new Pattern("DAMIAN",24); console.log(pat); var fract = pat.getFract(); var val = fract.valueOf(); console.log(fract.toString()); console.log(val.toString(24));

In this example I encode my name into a division pattern. AS you can see the pattern is displayed first. Then fraction. Then value in base 24.

You can encode things like this if you like. When I display the value my name is 0.DAMIAN
DAMID
.

It gets cut off at DAMID the second time. The last digit should be an A, but it is cut off as it is the last partial digit of accuracy in the floating point value.

IF you do not specify the number base. The pattern data type will default to binary. Since numbers are binary in the computer by default.

var pat = new Pattern("1011"); console.log(pat); var fract = pat.getFract(); var val = fract.valueOf(); console.log(fract.toString()); console.log(val.toString(2));

It is fun working with numbers in different divisible parts.

However you have to remind yourself that it is all in binary place values. Even though we can round stuff off, and divide by different place values.

Finding the division pattern.

Lets say you wish to find what the periodic pattern of a fraction, or number is.

var f = new Fract(711,911); var val = f.valueOf(); console.log(val.toString(2)); console.log(f.toString()); var pat = f.divP(); console.log(pat.toString());

You start by creating a fraction. You then call the operation divP. Which divides the value in binary. It finds the two points that equal the same remainder. Then creates the pattern.

In the example code. The first output is the value of the fraction in binary. The second output is the fraction. Then last output is the division pattern before any recurrence.

Assuming you wish to find the division pattern of a value. You then get the fraction of the value then call divP.

var val = 711 / 911; console.log(val.toString(2)); var f = val.getFract(); var pat = f.divP(); console.log(pat.toString());

Now all of this is done in binary by default. You can actually pass the number base you want to divP.

This will then force division pattern in other number bases like base 10.

var f = new Fract(711,911); var val = f.valueOf(); console.log(val.toString()); console.log(f.toString()); var pat = f.divP(10); console.log(pat.toString());

And lets say you wish to convert to a base 10 pattern from just the number value.

var val = 711 / 911; console.log(val.toString()); var f = val.getFract(); var pat = f.divP(10); console.log(pat.toString());

Fraction data type.

Fractions are useful for values that are periodic. See the section on Periodic number patterns: Link.

Such values should be avoided if possible by storing the fraction instead, or splitting such numbers into parts. Then adding the parts back to a fraction.

However the fraction data type is not useful for numbers that are a infinite pattern of parts. This is because such values can never be a finite value. See the section Irrational numbers: Link.

In binary. Lots of decimal values become un-dividable in place values of two. See the following documentation: Link.

Such values can be converted into two floating point values that divide to the value without error. Which is what the fraction data type does.

The reason it works is that we can store numbers as whole numbers in binary without error. Then add them. Then divide to the exact number.

var f1 = new Fract(1,10); var f2 = new Fract(2,10); //Add the two fractions. f1.x += f2.x; //Display the result. console.log(f1);

Now normally adding 0.1 with 0.2 would create a floating point error. However it does not this time. Because we are using whole number values that can be represented in binary perfectly.

You can multiply, add, and subtract. Such values without any errors as the fraction data type.

Each fraction has a x, and y.

x is the numerator floating point value.

y is the denominator floating point number.

This form of arithmetic is preferred in applications that require extremely high accuracy with very little impact on performance.

Now adding 0.1, and 0.2 regularly as follows will result in error.

var f1 = 0.1; var f2 = 0.2; //Add the two numbers. f1 += f2; //Display the result. console.log(f1);

The reduce method splits the fraction into parts then adds the parts back into the smallest fraction.

var f = new Fract(31415,10000); //Display fraction. console.log(f.toString()); //Smallest fraction. f = f.reduce(); //Display the result. console.log(f.toString());

The Fraction data type lets you use the divP method to find what the indivisible pattern is.

var f = new Fract(2,10); //Indivisible part in binary base 2. var pat = f.divP(2); //Display the indivisible pattern. console.log(pat);

So 0.2 ends up having the recurring pattern 0011∞ forever. You can change the divP(2) to other number bases if you wish to find if the fraction is dividable in other number bases other than binary.

For example if you change base 2 to base 10 with divP(10). Then you will get the output 0∞. This means there is no reminder. Which means it divides in base 10, but not as a base 2 binary number.

You can only use divP with the fraction data type.

The method getFract gives back a fraction from numbers, and patterns. By splitting to all parts then adding all parts back to a fraction.

It is methods splitAll, and calcF combined.

Also Method calcF gives back the fraction data type. Which also would allow you to use divP with added up parts.

It is important for you to know this so you do not use a method like divP, or even reduce. Unless you convert to a fraction data type first.

Error Correction.

Generally error correction is not rally necessary. If you write your code, and algorithms using the fraction data type: Link.

In that section. I explain floating point error, and how to overcome it. With as little performance loss as possible.

Errors happen at the last place value in a number. When you add values together that do not divide evenly into a binary number.

When a number is split into parts. The last part is usually where the error is accumulated.

However removing the last part. Is not possible. If there is no error. As it will create a less accurate number when added back together. Resulting in error.

What we can do. Is that the part ends up being rally big in size compared to the other A, B parts. So we average the parts. Then remove the parts at the end of the number that are bigger than average.

So here is an example where we introduce error into a floating point value. Then error correct it.

var n = 3.147547; var er = 2; //Number Of binary digits. //The exponent position using log 2. var pos = Math.round(Math.log(n)/Math.log(2)); //The last binary digit. var er = 2**(pos-(53-er)); er -= 2**(pos-53); //Show the error that is being introduced. console.log( "Value before error is introduced.\r\n\r\n" + n.toString(2) + "\r\n\r\n" ); console.log( "Value that is going to be added to Number as error.\r\n\r\n" + er.toString(2) + "\r\n\r\n" ); n += er; console.log( "Value After error is introduced.\r\n\r\n" + n.toString(2) + "\r\n\r\n" ); //Show various stats about the number in question. n.stats(); //Call the error correction method on the number. console.log( "\r\n\r\nError corrected value = " + n.err() );

In this example I use the method stats. It displays everything about any number you use it with.

As you can see there is a big jump at the last part.

Generally we only need to remove the part at the end of the number. Going backwards that is higher than average.

When the method err is used on a number. It gives back the number value error corrected.

There is a lot you can change in this example code if you like. You can change the number used which is variable "n". You can make the error bigger by change the "er = 2" to say "er = 5".

To Average fraction.

There are also other forums of error correction such as translating to a average fraction.

Rather than calling getFract on numbers, or using getFract on the pattern data type. Instead you can use avgFract.

var n = 3.147547; var er = 2; //Number Of binary digits. //The exponent position using log 2. var pos = Math.round(Math.log(n)/Math.log(2)); //The last binary digit. var er = 2**(pos-(53-er)); er -= 2**(pos-53); //Show the error that is being introduced. console.log( "Value before error is introduced.\r\n\r\n" + n.toString(2) + "\r\n\r\n" ); console.log( "Value that is going to be added to Number as error.\r\n\r\n" + er.toString(2) + "\r\n\r\n" ); n += er; console.log( "Value After error is introduced.\r\n\r\n" + n.toString(2) + "\r\n\r\n" ); //Show various stats about the number in question. n.stats(); //Call the error correction method on the number. console.log( "\r\n\r\nError corrected value = " + n.avgFract().toString() );

This time when error correcting the value. We convert to a fraction that is the average of all "a" parts.

This is very useful if you wish to receive number inputs from a septate method, or routine. That you know may have error.

You then can translate to a fraction. Then you can do arithmetic with fraction data types. To have less error overall.

Setting a limit.

The last forum of error correction is setting a cut off range. Normally the cut off range is the last digit in a floating point number.

The last floating point digit is 53 away in place values of 2. So 2^52=4503599627370496 as a number. Which has a move-able exponent.

We then divide this large number into one to get a value at which the number is cut off at.

In which 1÷4503599627370496=2.22044604925031-16 is the default cut off range when spiting a number into parts.

The methods split, splitAll use this value to find when all parts are split out of the number.

The methods getFract, avgFract use this value as well to convert to fraction. As they split to the last part of the number.

The method Trans, Stops transforming all parts at the cut off range.

var pi = Math.PI; pi = pi.splitAll(); console.log(pi.toString()); //Set the limit. pi.limit( 1 / Math.pow(2, 26 ) ); console.log(pi.toString());

AS you can see. The first time we split to all parts. We split right to the end. After we set the limit to half of 52, which is 26. We then have over 50% of the number gone.

The value is set 0 at cut off range. In this next example the limit is set back to normal.

var pi = Math.PI; pi = pi.splitAll(); console.log(pi.toString()); //Set the limit. pi.limit( 1 / Math.pow(2, 26 ) ); console.log(pi.toString()); //Set limit back to normal. pi.limit( 1 / Math.pow(2, 52 ) ); //Split to all parts again. pi = pi.splitAll(); console.log(pi.toString());

You can change the limit how ever you like without losing the value of the number. It just sets the 0 point.

Also if you do not like the limit as a positional number in place values. You can convert to out of 52 place values into a percentage of 0% to 100%.

var ac = 50; var pi = Math.PI.limit( 1 / ( Math.pow( 2, 52 / ( 100 / ac ) ) ) ); var fract = pi.getFract(); console.log(fract.toString());

You can go by percent, or number of places.

Setting the cut off point is good, for error correcting a value. If you know the number of adds, multiply, basically arithmetic operations that occurred.

You then can add up the max possible error into number of place values. This is called dynamic error correction.

Binary translation operations.

You can convert the number into pure binary using the bits operation. Once the number is in binary. You can manipulate the exponent, mantissa, and even the sing bit.

var val = 27.34; val = val.bits(); console.log(val.toString()); val.sing = 1; val.exp += 1; val.mantissa += 1; console.log(val.toString());

In this example we convert the number to it's 64 bit binary value using toString. We set the sing bit one at the start of the number that can be a 0, or 1. We move the exponent one place value. Which the exponent is the next 11 binary digits after the sing. Then we add our 52 binary digits of our number by one.

As you can see the binary value from before then after. You can make any floating point number manipulation you like using this.

If toString is not used the floating point value is used.

var val = 27.34; val = val.bits(); console.log(val); val.sing = 1; val.exp += 1; val.mantissa += 1; console.log(val);

However doing any math operation with the binary number will convert the number back to a regular number.

var val = 27.34; val = val.bits(); val = val + 0; console.log(val); val.sing = 1; val.exp += 1; val.mantissa += 1; console.log(val);

It will convert back to a number. So if you want to do binary operations on it's sing, exponent, mantissa. You have to convert it back to binary with the bits method.

You can also change the 64 bit binary representation into any number base from 2 to 36 per place value.

var val = 27.34; val = val.bits(); console.log(val.toString(10));

You can also convert any 64 bit binary representation of a number back into a number with the new parseNumber method.

var val = parseNumber("04628388743545398231", 10); console.log(val);

Normally this method translates 64 binary digits to a floating point number if you leave out the ", 10".

var val = parseNumber("0100000000111011010101110000101000111101011100001010001111010111"); console.log(val);

This time just the 64 bit binary value is used by default. If no number base is specified.

Also the parseFloat operation has been updated to Handel changing floating point numbers in different bases back to a number value.

For example the number PI in base 36.

var val = Math.PI; console.log(val.toString(36));

Now with the updated parseFloat. We can convert the value back to it's exact number by specifying base 36.

var val = parseFloat("3.53I5AB8P5F", 36); console.log(val);

Working with number bases like this with perfect accuracy was not possible before. If you remove ", 36". Then the default is base 10.

var val = parseFloat("3.141592653589793"); console.log(val);

The round off point is calculated in multiples relative to the rounding off point in binary. This ensures there is no loss when changing numbers between different number bases.

However you can view what the real value looks like in full. Because 0.1 is indivisible as a binary number. So it is rounded off at 0.1 in decimal relative to the last multiple of 10 that is accurate in binary place values.

var val = 0.1; console.log( val.toString( 10, true ) );

This gives us the decimal value 0.10000000000000000555111512312578270211815834045410156. Which is rounded off to 0.1. Almost all decimal values do not divide evenly as a binary number.

See the following documentation on why: Link.

Using ", true" forces the true representation of a floating point value, without any rounding off in any number base, from 2 to 36.

var val = Math.PI; console.log( val.toString( 10, true ) );

The best representation of PI without any rounding off as a 64 bit floating point number is exactly 3.141592653589793115997963468544185161590576171875.

It is rounded off at 3.141592653589793. As that is the only places that are truly accurate to number of binary digits in a floating point number.

var val = Math.PI; console.log( val.toString( 36, true ) );

The real representation of PI in base 36. Without any rounding off as a 64 bit floating point number is exactly 3.53I5AB8P5FC5VAYQTER60F6R.

Bitwise Operations.

You can now do logical operations on all 64 binary digits of a floating point number.

Doing any bitwise operation on a floating point number changes the number into a binary number. See the section on binary translation: Link.

Before javascript would convert to a 32 bit number during logical operations. Then back to a floating point number.

Lets start with one of the basics such as a left shift.

var n = Math.PI; for( var i = 0; i < 64; i++ ) { n = n.bitLsh(1); console.log(n.toString()); }

In this example we left shift the number 64 times by 1. What this does it move all the binary digits to the left by one.

The number gets converted to a binary number as soon as you do any logical bitwise operation on the floating point number.

You can also display the decoded float value if you remove the toString method. Which is the regular behavior for a binary number.

var n = Math.PI; for( var i = 0; i < 64; i++ ) { n = n.bitLsh(1); console.log(n); }

This differs greatly as it rally does let you do 64 bit bitwise arithmetic operations as a floating point value.

var n = Math.PI; for( var i = 0; i < 64; i++ ) { n = n.bitRsh(1); console.log(n.toString()); console.log(n); }

Also bitRsh is right shift. It is the same as left shift. Except it moves the binary digits to the right. Number of places. Instead of to the left.

You can change the number of places from 1 at a time to 2 at a time to the right or more if you like.

You can also do operations like the logical "NOT" operation which converts all ones to zeros, and all zeros to ones. It inverts the binary number.

var n = Math.PI; n = n.bits(); console.log(n); console.log(n.toString()); n = n.bitNot(); console.log(n); console.log(n.toString());

This time I convert the number to it's binary using the bit's operation, so I can show the binary value before the bits based operation "NOT".

As you can see the two numbers are opposite to each other. Inverting a floating point number is very inserting. For example you can change var n = Math.PI; to var n = 7;. Change the value to what ever you like.

Then we have operations like "XOR", "AND", "OR".

var n = Math.PI; n = n.bits(); console.log(n); console.log(n.toString()); n = n.bitAnd(2.1); console.log(n); console.log(n.toString());

In this example we do a logical "AND" against the number PI with the 64 bit floating point value "2.1".

The value 2.1 in binary is 0100000000000000110011001100110011001100110011001100110011001101

The number PI is 0100000000001001001000011111101101010100010001000010110100011000

The logical "AND" operations only outputs a one if the two binary digits are a 1 in the same place values. This creates a very interesting operation when it comes to floating point numbers.

var n = Math.PI; n = n.bits(); console.log(n); console.log(n.toString()); n = n.bitOr(2.1); console.log(n); console.log(n.toString());

This time we do a logical "OR" with the same values we did with the logical "AND" operation.

The logic operation "OR" outputs a 1 if aether place values from both numbers are a 1. So it sets the place value a one if it is a one in aether number merging the place values. Except place values that are both 0 in both numbers.

This also has some interesting effects on floating point numbers when comparing them just as logical "AND" does.

var n = Math.PI; n = n.bits(); console.log(n); console.log(n.toString()); n = n.bitXor(2.1); console.log(n); console.log(n.toString());

The logical XOR operation only outputs a 1 if both place values are different. If both place are the same output is 0.

Doing a XOR with the same number will result in 0 all across the number since the binary digits are the same. Thus you only get a one output if digits do not match.

Also you do not have to use just 2.1 as the value you do a "XOR", "AND", "OR", operation with. You can also change Math.PI to any number you like.

Vector and array operations.

We can also do all the floating point operations on a group of numbers rather than one number at a time.

var array = [7, 7.7, 9.11, 3.11, 723]; array = array.bits(); console.log(array.join("\r\n"));

As you can see all numbers in the array are converted to binary numbers with the bits operation.

Thus join is an array operation. It converts all numbers in the array toString using the toString operation on all numbers in the array.

The input "\r\n" is what we wish to use as a separator between each thing in the array. Thus "\r\n" is the code for a new line.

var array = [7, 7.7, 9.11, 3.11, 723]; array = array.getFract(); console.log(array.join("\r\n"));

Call the method getFract on all numbers in the array. Basically all operations. You would use on a single number. Is usable with array.

This makes a big shortcut, for writing algorithms, and code to also error correct all numbers with a single err on an array.

var array = [7, 7.7, 9.11, 3.11, 723]; array = array.bitRsh(1); console.log(array.join("\r\n"));

Right shift all numbers by one. All number operations can be used with a group of numbers in an array.