Movatterモバイル変換


[0]ホーム

URL:


Next:, Up:Arithmetic onpoly_ints   [Contents][Index]


9.4.1 Usingpoly_int with C++ arithmetic operators

The following C++ expressions are supported, wherep1 andp2arepoly_ints and wherec1 andc2 are scalars:

-p1~p1p1 +p2p1 +c2c1 +p2p1 -p2p1 -c2c1 -p2c1 *p2p1 *c2p1 <<c2p1 +=p2p1 +=c2p1 -=p2p1 -=c2p1 *=c2p1 <<=c2

These arithmetic operations handle integer ranks in a similar wayto C++. The main difference is that every coefficient narrower thanHOST_WIDE_INT promotes toHOST_WIDE_INT, whereas inC++ everything narrower thanint promotes toint.For example:

poly_uint16     + int          -> poly_int64unsigned int    + poly_uint16  -> poly_int64poly_int64      + int          -> poly_int64poly_int32      + poly_uint64  -> poly_uint64uint64          + poly_int64   -> poly_uint64poly_offset_int + int32        -> poly_offset_intoffset_int      + poly_uint16  -> poly_offset_int

In the first two examples, both coefficients are narrower thanHOST_WIDE_INT, so the result has coefficients of typeHOST_WIDE_INT. In the other examples, the coefficientwith the highest rank “wins”.

If one of the operands iswide_int orpoly_wide_int,the rules are the same as forwide_int arithmetic.


[8]ページ先頭

©2009-2026 Movatter.jp