Difference between revisions of "Fractions"

From ZCubes Wiki
Jump to navigation Jump to search
Line 8: Line 8:
 
</pre>
 
</pre>
  
z^3 uses the following notation for fractions.
+
z^3 uses the following notation for fractions. 2%%3 for 2/3, (1.2%%3) for 1 2/3 etc.  
2%%3 for 2/3
 
(1.2%%3) for 1 2/3
 
etc.  
 
  
 
5%%5<+>4%%5
 
5%%5<+>4%%5
  
gives 1.8
+
gives 1 4/5
  
To convert the results to fractions, use %% operator at the end of the expression.
 
 
(5%%5<+>4%%5)%%
 
 
gives
 
 
1 4/5
 
  
 
Note fraction additions etc. uses the Unit Conversion operators such as <+>, <->, etc. Hence it is also possibly to convert to meters etc.
 
Note fraction additions etc. uses the Unit Conversion operators such as <+>, <->, etc. Hence it is also possibly to convert to meters etc.
Line 30: Line 20:
  
 
gives 1m.
 
gives 1m.
 +
 
 
((4%%5)<+>((1.3%%5)<>m))%%
+
((4%%5)<+>((1.3%%5)<>m))
  
gives  
+
gives 2 2/5m
 
 
2 2/5m
 
 
 
  
 
((4%%5)<>m)<+>((1.3%%5)<>m)
 
((4%%5)<>m)<+>((1.3%%5)<>m)
  
2.4000000000000004m
+
gives 2 2/5m
  
  
 
(4%%5)<+>((1.3%%5)<>m)  
 
(4%%5)<+>((1.3%%5)<>m)  
  
2.4000000000000004m
+
gives 2 2/5m
  
  
 
((34%%5)<>m)<+>((1.3%%5)<>m)  
 
((34%%5)<>m)<+>((1.3%%5)<>m)  
  
8.4m
+
gives 8 2/5m
  
  
 
((3.4%%5)<>m)<+>((1.3%%5)<>m)  
 
((3.4%%5)<>m)<+>((1.3%%5)<>m)  
  
5.4m
+
gives 5 2/5m
 +
 
  
 
(((3.4%%5)<>m)<+>((1.3%%5)<>m))%%
 
(((3.4%%5)<>m)<+>((1.3%%5)<>m))%%
  
5 1250000000000001/3125000000000000
+
gives 5 2/5m
  
 
etc.
 
etc.

Revision as of 05:34, 16 May 2020

You can do computations on fractions in Z3

FRACTION("1 1/2").add(FRACTION("1 1/2"));
FRACTION("1 1/3").subtract(FRACTION("1 1/2"));
FRACTION("1 1/3").multiply(FRACTION("2 5/3"));
FRACTION("1 1/3").divide(FRACTION("2 5/3"));

z^3 uses the following notation for fractions. 2%%3 for 2/3, (1.2%%3) for 1 2/3 etc.

5%%5<+>4%%5

gives 1 4/5


Note fraction additions etc. uses the Unit Conversion operators such as <+>, <->, etc. Hence it is also possibly to convert to meters etc.

(4%%5)<+>((1%%5)<>m)

gives 1m.


((4%%5)<+>((1.3%%5)<>m))

gives 2 2/5m


((4%%5)<>m)<+>((1.3%%5)<>m)

gives 2 2/5m


(4%%5)<+>((1.3%%5)<>m)

gives 2 2/5m


((34%%5)<>m)<+>((1.3%%5)<>m)

gives 8 2/5m


((3.4%%5)<>m)<+>((1.3%%5)<>m)

gives 5 2/5m


(((3.4%%5)<>m)<+>((1.3%%5)<>m))%%

gives 5 2/5m

etc.