Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

Making a Programming Language From Scratch/Comparing Two Values

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

Comparisons Comparisons in programming are the logical comparison between two data types of the same type to determine which is larger, or which is smaller or if both are equal. Based on the result thus derived which is a Boolean value ( 1 or 0 ) certain statements are executed or not. Whole number comparisons Whole numbers include chars and ints of all types. The basic format for all comparisons is the same. CMP [ operand1 ] [ operand2 ] The conditional jumps based on this result are : JL or jnge for lesser than Jle or jng for lesser than equal to JG or Jnle for greater than Jge or Jnl for greater than equal to Je for equal to Jne for not equal to Floatational comparisons The syntax for floatational comparisons are more complex. Fld [ operand1 ] Fld [ operand2 ] Fcompp Fstsw ax Sahf Comparisons based on this are: Jc for lesser than Jce for lesser than equal to Je for equal to Jne for not equal to Ja for greater than Jae for greater than equal to Add sample conversions Logical appendations Logical appendations are when two or more conditions are logically connected such that the result of one influences the result of the other. For example: If(a>b&&b>c){ This condition depends on both the logical relations of a,b and c. If any one of the double conditions are false the resultant output is false. The counterpart the || operator is used for or relations, i.e if any one of the double conditions are true then the resultant is also true. Note that these logical operators can be used for more than two conditions.