⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 c2

📁 UNIX v6源代码 这几乎是最经典的unix版本 unix操作系统设计和莱昂氏unix源代码分析都是用的该版
💻
📖 第 1 页 / 共 2 页
字号:
former is converted to \fGdouble\fR, and the result is \fGdouble\fR;if both are \fGfloat\fR or \fGdouble\fR, the result is \fGdouble\fR.No other combinations are allowed..ms7.3.2  \fIexpression \fG/\fI expression\fR.etThe binary \fG/\fR operator indicates division.The same type considerations as for multiplicationapply..ms7.3.3  \fIexpression \fG%\fI expression\fR.etThe binary \fG%\fR operator yields the remainderfrom the division of the first expression by the second.Both operands must be \fGint\fR or \fGchar\fR, and theresult is \fGint\fR.In the current implementation,the remainder has the same sign as the dividend..ms7.4  Additive operators.etThe additive operators \fG+\fR and \fG\(mi\fR group left-to-right..ms7.4.1  \fIexpression \fG+\fI expression\fR.etThe result is the sum of the expressions.If both operands are \fGint\fR or \fGchar\fR,the result is \fGint\fR.If bothare \fGfloat\fR or \fGdouble\fR, the result is \fGdouble\fR.If one is \fGchar\fR or \fGint\fR and one is \fGfloat\fRor \fGdouble\fR, the former is converted to \fGdouble\fR and the result is \fGdouble\fR.If an \fGint\fR or \fGchar\fR is added to a pointer, the formeris converted by multiplying itby the length of the object to which thepointer points and the result is a pointerof the same type as the original pointer.Thus if P is a pointerto an object, the expression ``P+1'' is a pointerto another object of the same type asthe first and immediately followingit in storage..pgNo other type combinations are allowed..ms7.4.2  \fIexpression \fG\(mi \fIexpression\fR.etThe result is the difference of the operands.If both operands are \fGint\fR, \fGchar\fR, \fGfloat\fR, or \fGdouble\fR,the same type considerationsas for \fG+\fR apply.If an \fGint\fR or \fGchar\fR is subtractedfrom a pointer, theformer is converted in the same way as explained under\fG+\fR above..pgIf two pointers to objects of the same type are subtracted,the result is converted(by division by the length of the object)to an \fGint\fR representing the number ofobjects separatingthe pointed-to objects.This conversion will in general give unexpectedresults unless the pointers pointto objects in the same array, since pointers, evento objects of the same type, do not necessarily differby a multiple of the object-length..ms7.5  Shift operators.etThe shift operators \fG<<\fR and \fG>>\fR group left-to-right..ms7.5.1  \fIexpression \fG<< \fIexpression\fR.br7.5.2  \fIexpression \fG>> \fIexpression\fR.etBoth operands must be \fGint\fR or \fGchar\fR,and the result is \fGint\fR.The second operand shouldbe non-negative.The value of ``E1<<E2'' is E1 (interpreted as a bitpattern 16 bits long) left-shifted E2 bits;vacated bits are 0-filled.The value of ``E1>>E2'' is E1 (interpreted as a two'scomplement, 16-bit quantity) arithmeticallyright-shifted E2 bit positions.Vacated bits are filled by a copy of the sign bit of E1.[Note: the useof arithmetic rather than logical shift does notsurvive transportation between machines.].ms7.6  Relational operators.etThe relational operators group left-to-right, butthis fact is not very useful; ``a<b<c'' doesnot mean what it seems to..ms7.6.1  \fIexpression \fG<\fI expression\fR.br.ne 47.6.2  \fIexpression \fG>\fI expression\fR.br.ne 47.6.3  \fIexpression \fG<=\fI expression\fR.br.ne 47.6.4  \fIexpression \fG>=\fI expression\fR.etThe operators < (less than), > (greater than), <= (less thanor equal to) and >= (greater than or equal to)all yield 0 if the specified relation is falseand 1 if it is true.Operand conversion is exactly the same as for the \fG+\fRoperator except that pointers of any kind may be compared;the result in this case depends on the relativelocations in storage of the pointed-to objects.It does not seem to be very mean$ing$fulto compare pointers with integersother than 0..ms.ti 07.7  Equality operators.et.ne 4.ti 07.7.1  \fIexpression \fG==\fI expression\fR.br.ne 47.7.2  \fIexpression \fG!=\fI expression\fR.etThe \fG==\fR (equal to) and the \fG!=\fR (not equal to) operatorsare exactly analogous to the relationaloperators except for their lowerprecedence.(Thus ``a<b@==@c<d'' is 1 whenevera<b and c<dhave the same truth-value)..ms7.8  \fIexpression \fG&\fI expression\fR.etThe \fG&\fR operator groups left-to-right.Both operands must be \fGint\fR or \fGchar\fR;the result is an \fGint\fR which is the bit-wiselogical \fGand\fR function of the operands..ms.tr ^^7.9  \fIexpression \fG^ \fIexpression\fR.etThe \fG^\fR operator groups left-to-right.The operands must be \fGint\fR or \fGchar\fR; the result is an \fGint\fRwhich is the bit-wise exclusive \fGor\fR function ofits operands..tr ^\|.ms7.10  \fIexpression ^\(or \fIexpression\fR.etThe \(or operator groups left-to-right.The operands must be \fGint\fR or \fGchar\fR; the result is an \fGint\fRwhich is the bit-wise inclusive \fGor\fR of its operands..ms7.11  \fIexpression \fG&&\fI expression.etThe \fG&&\fR operator returns 1 if both its operandsare non-zero, 0 otherwise.Unlike \fG&\fR, \fG&&\fR guarantees left-to-rightevaluation; moreover the second operand is not evaluatedif the first operand is 0..pgThe operands need not have the same type, but eachmust have one of the fundamentaltypes or be a pointer..ms7.12  \fIexpression ^\(or\(or \fIexpression.etThe ^\(or\(or operator returns 1 if either of its operandsis non-zero, and 0 otherwise.Unlike ^\(or^,^\(or\(or guarantees left-to-right evaluation; moreover,the second operand is not evaluatedif the value of the first operand is non-zero..pgThe operands need not have the same type, but eachmusthave one of the fundamental typesor be a pointer..ms7.13  \fIexpression \fG? \fIexpression \fG:\fI expression\fR.etConditional expressions group left-to-right.The first expression is evaluatedand if it is non-zero, the result is the value of thesecond expression, otherwise that of third expression.If the types of the second and third operand are the same, theresult has their common type;otherwise the same conversion rules as for \fG+\fRapply.Only one of the second and thirdexpressions is evaluated..ms7.14  Assignment operators.etThere are a number of assignment operators,all of which group right-to-left.All require an lvalue as their left operand,and the type of an assignment expression is thatof its left operand.The value is the value stored in theleft operand after the assignment has taken place..ms7.14.1  \fIlvalue \fG= \fIexpression\fR.etThe value of the expression replaces that of the objectreferredto by the lvalue.The operands need not have the same type, butboth must be\fGint\fR, \fGchar\fR, \fGfloat\fR, \fGdouble\fR,or pointer.If neither operand is a pointer,the assignment takes place as expected, possiblypreceded by conversion of the expression on the right..pgWhen both operands are \fGint\fRor pointers of any kind, no conversionever takes place;the value of the expression is simply storedinto the object referred to by the lvalue.Thus it is possible togenerate pointers which will cause addressingexceptions when used..ms.ta \w'0.00.00 'u7.14.2	\fIlvalue \fG=+ \fIexpression\fR.br7.14.3	\fIlvalue \fG=\(mi \fIexpression\fR.br7.14.4	\fIlvalue \fG=\** \fIexpression\fR.br7.14.5	\fIlvalue \fG=/ \fIexpression\fR.br7.14.6	\fIlvalue \fG=% \fIexpression\fR.br7.14.7	\fIlvalue \fG=>> \fIexpression\fR.br7.14.8	\fIlvalue \fG=<< \fIexpression\fR.br7.14.9	\fIlvalue \fG=& \fIexpression\fR.br.tr ^^7.14.10	\fIlvalue \fG=^ \fIexpression\fR.br.tr ^\|7.14.11	\fIlvalue \fG=^\(or \fIexpression\fR.etThe behavior of an expressionof the form ``E1@=op@E2'' may be inferred bytaking it as equivalent to ``E1@=@E1@op@E2'';however, E1 is evaluated only once.Moreover,expressions like ``i@=+@p''in which a pointer is added to an integer, are forbidden..ms7.15  \fIexpression \fG,\fI expression\fR.etA pair of expressions separated by a comma is evaluatedleft-to-right and the value of the left expression isdiscarded.The type and value of the result are thetype and value of the right operand.This operator groups left-to-right.It should be avoided in situations where comma is givena special meaning, for example in actual argumentsto function calls (\(sc7.1.6) and lists of initializers (\(sc10.2).

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -