manual:chapter3:reals

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Last revision Both sides next revision
manual:chapter3:reals [2019/11/04 16:06]
jojo1973 More reformatting
manual:chapter3:reals [2019/11/05 16:32]
jojo1973 Added more commands
Line 109: Line 109:
 | ''[[manual:chapter6:binary:cmd_bmul|BMUL]]'' | Multiply | ''#1A4h #7h [[manual:chapter6:binary:cmd_bmul|BMUL]]'' | | ''[[manual:chapter6:binary:cmd_bmul|BMUL]]'' | Multiply | ''#1A4h #7h [[manual:chapter6:binary:cmd_bmul|BMUL]]'' |
 | ''[[manual:chapter6:binary:cmd_bdiv|BDIV]]'' | Divide | ''12 5 [[manual:chapter6:binary:cmd_bdiv|BDIV]]'' | | ''[[manual:chapter6:binary:cmd_bdiv|BDIV]]'' | Divide | ''12 5 [[manual:chapter6:binary:cmd_bdiv|BDIV]]'' |
-| ''[[manual:chapter6:binary:cmd_bneg|BNEG]]'' | Negate (two'complement) | ''#11001b [[manual:chapter6:binary:cmd_bneg|BNEG]]'' |+| ''[[manual:chapter6:binary:cmd_bneg|BNEG]]'' | Negate (Two'Complement) | ''#11001b [[manual:chapter6:binary:cmd_bneg|BNEG]]'' |
 | ''[[manual:chapter6:binary:cmd_band|BAND]]'' | Bitwise AND | ''#1101010b #1100010b [[manual:chapter6:binary:cmd_band|BAND]]'' | | ''[[manual:chapter6:binary:cmd_band|BAND]]'' | Bitwise AND | ''#1101010b #1100010b [[manual:chapter6:binary:cmd_band|BAND]]'' |
 | ''[[manual:chapter6:binary:cmd_bor|BOR]]'' | Bitwise OR | ''#1101010b #1100010b [[manual:chapter6:binary:cmd_bor|BOR]]'' | | ''[[manual:chapter6:binary:cmd_bor|BOR]]'' | Bitwise OR | ''#1101010b #1100010b [[manual:chapter6:binary:cmd_bor|BOR]]'' |
 | ''[[manual:chapter6:binary:cmd_bxor|BXOR]]'' | Bitwise XOR | ''#1101010b #1100010b [[manual:chapter6:binary:cmd_bxor|BXOR]]'' | | ''[[manual:chapter6:binary:cmd_bxor|BXOR]]'' | Bitwise XOR | ''#1101010b #1100010b [[manual:chapter6:binary:cmd_bxor|BXOR]]'' |
-| ''[[manual:chapter6:binary:cmd_bnot|BNOT]]'' | Bitwise NOT (one'complement) | ''#11001b [[manual:chapter6:binary:cmd_bNOT|BNOT]]'' |+| ''[[manual:chapter6:binary:cmd_bnot|BNOT]]'' | Bitwise NOT (One'Complement) | ''#11001b [[manual:chapter6:binary:cmd_bnot|BNOT]]'' | 
 +| ''[[manual:chapter6:binary:cmd_blsl|BLSL]]'' | Bitwise Logical Shift Left | ''#11001b 4 [[manual:chapter6:binary:cmd_blsl|BLSL]]''
 +| ''[[manual:chapter6:binary:cmd_blsr|BLSR]]'' | Bitwise Logical Shift Right | ''#11001b 2 [[manual:chapter6:binary:cmd_blsr|BLSR]]''
 +| ''[[manual:chapter6:binary:cmd_basr|BASR]]'' | Bitwise Arithmetic Shift Right | ''#215o 2 [[manual:chapter6:binary:cmd_basr|BASR]]''
 +| ''[[manual:chapter6:binary:cmd_brl|BRL]]'' | Bitwise Rotate Left | ''#3FFh 4 [[manual:chapter6:binary:cmd_brl|BRL]]''
 +| ''[[manual:chapter6:binary:cmd_brr|BRR]]'' | Bitwise Rotate Right | ''#3FFh 1 [[manual:chapter6:binary:cmd_brr|BRR]]''
 + 
 +---- 
 + 
 +==== Testing ==== 
 + 
 +Real numbers form an ordered set and its elements can be compared: **newRPL** provides a full set of arithmetic and logic operators plus some specialized ones. 
 + 
 +All these operators (except ''[[manual:chapter6:operators:cmd_ovr_cmp|CMP]]'') return ''1'' __if the test is true__ and ''0'' __if the test is false__. Actually any value different from ''0'' is considered __true__, but conventionally the operators return always ''1'' when the test succeeds. 
 + 
 +The classical **arithmetic** test operators are ''[[manual:chapter6:operators:cmd_ovr_eq|==]]'' (equality), ''[[manual:chapter6:operators:cmd_ovr_noteq|≠]]'' (not equality), ''[[manual:chapter6:operators:cmd_ovr_lt|<]]'' (less than), ''[[manual:chapter6:operators:cmd_ovr_gt|>]]'' (greater than), ''[[manual:chapter6:operators:cmd_ovr_lte|≤]]'' (less than or equal), ''[[manual:chapter6:operators:cmd_ovr_gte|≥]]'' (greater than or equal). 
 + 
 +<code> 
 +2:                          #10h 
 +1:                       #10000b 
 +…………………………………………………………………………………… 
 +== 
 +</code> yields ''1''
 + 
 +<code> 
 +2:                          #11o 
 +1:                           10. 
 +…………………………………………………………………………………… 
 +
 +</code> yields ''0''
 + 
 +**Logical** test operators are ''[[[manual:chapter6:operators:cmd_ovr_and|AND]]'', ''[[[manual:chapter6:operators:cmd_ovr_or|OR]]'', ''[[[manual:chapter6:operators:cmd_ovr_xor|XOR]]'' and ''[[[manual:chapter6:operators:cmd_ovr_not|NOT]]''
 + 
 +These operators must not be confused with the similar named bitwise operators ''[[manual:chapter6:binary:cmd_band|BAND]]'', ''[[manual:chapter6:binary:cmd_bor|BOR]]'', ''[[manual:chapter6:binary:cmd_bxor|BXOR]]'' and ''[[manual:chapter6:binary:cmd_bnot|BNOT]]'' described earlier: while the latter operate on a bit-by-bit basis, the logical operators consider the //truth value// of their arguments. Some examples will help to clarify: 
 + 
 +<code> 
 +2:                        #1000b 
 +1:                       #11000b 
 +…………………………………………………………………………………… 
 +BAND 
 +</code> 
 +yields ''#1000b'', but 
 +<code> 
 +2:                        #1000b 
 +1:                       #11000b 
 +…………………………………………………………………………………… 
 +AND 
 +</code> 
 +yields ''1''. Similarly 
 +<code> 
 +2:                        #1000b 
 +1:                           #0b 
 +…………………………………………………………………………………… 
 +BOR 
 +</code> 
 +yields ''#1000b'', but 
 +<code> 
 +2:                        #1000b 
 +1:                           #0b 
 +…………………………………………………………………………………… 
 +AND 
 +</code> 
 +yields ''0''
 + 
 +Finally, **specialized** test operators perform particular tests: they are ''[[manual:chapter6:operators:cmd_ovr_cmp|CMP]]'', ''[[manual:chapter6:operators:cmd_ovr_same|SAME]]'' and ''[[manual:chapter6:operators:cmd_ovr_istrue|ISTRUE]]''
 + 
 +''[[manual:chapter6:operators:cmd_ovr_cmp|CMP]]'' returns the ''[[manual:chapter6:arithmetic:cmd_ovr_sign|SIGN]]'' of the difference between its arguments: 
 +<code> 
 +2:                            -2 
 +1:                             8 
 +…………………………………………………………………………………… 
 +CMP 
 +</code> 
 +yields ''-1''
 + 
 +For real numbers  
 +  * ''[[manual:chapter6:operators:cmd_ovr_same|SAME]]'' and ''[[manual:chapter6:operators:cmd_ovr_eq|==]]'' are equivalent; 
 +  * ''[[manual:chapter6:operators:cmd_ovr_istrue|ISTRUE]]'' and ''« 0 [[manual:chapter6:operators:cmd_ovr_noteq|≠]] »'' are equivalent. 
 + 
 +---- 
 +   
 +==== Special numbers ==== 
 + 
 +Operation on real numbers aren't always defined on the whole field of real numbers.
  • manual/chapter3/reals.txt
  • Last modified: 2019/11/06 15:21
  • by jojo1973