How to use only bit operations to implement afigb in ABAP
This article shows you how to use only bit operations in ABAP to achieve adirecb, the content is concise and easy to understand, can definitely brighten your eyes, through the detailed introduction of this article, I hope you can get something.
Implementation code:
REPORT zint.PARAMETERS: a TYPE int4 OBLIGATORY DEFAULT 100, b TYPE int4 OBLIGATORY DEFAULT 100. DATA: threshold TYPE int4.FORM add USING a TYPE int4 b TYPE int4 CHANGING cv_result TYPE int4. DATA: n TYPE int4 VALUE 0, c TYPE int4 VALUE 0. DATA: i TYPE int4 VALUE 1. DATA: boolean_a TYPE abap_bool, boolean_b TYPE abap_bool, _ a TYPE int4, _ b TYPE int4, aa TYPE int4, bb TYPE int4. DATA (wrapper_one) = zcl_integer= > value_of (1). DATA (wrapper_c) = zcl_integer= > value_of (c). Aa = a. Bb = b. WHILE I
< threshold. DATA(wrapper_a) = zcl_integer=>Value_of (aa). DATA (wrapper_b) = zcl_integer= > value_of (bb). Boolean_a = boolc (wrapper_a- > and (wrapper_one)-> get_raw_value () EQ 1). Boolean_b = boolc (wrapper_b- > and (wrapper_one)-> get_raw_value () EQ 1). _ a = COND int4 (WHEN boolean_a EQ abap_true THEN 1 ELSE 0). _ b = COND int4 (WHEN boolean_b EQ abap_true THEN 1 ELSE 0). Wrapper_a = zcl_integer= > value_of (a). Wrapper_b = zcl_integer= > value_of (_ b). Wrapper_c = zcl_integer= > value_of (c). DATA (_ n_wrapper) = wrapper_a- > xor (wrapper_b)-> xor (wrapper_c). DATA (b_or_c) = wrapper_b- > or (wrapper_c). DATA (b_and_c) = wrapper_b- > and (wrapper_c). DATA (_ c_wrapper) = wrapper_a- > and (b_or_c)-> or (b_and_c). C = _ clockwrapper-> get_raw_value (). DATA (_ n_i0_wrapper) = zcl_integer= > value_of (COND int4 (WHEN _ naughwrapper-> get_raw_value () > 0 THEN i ELSE 0)). DATA (wrapper_n) = zcl_integer= > value_of (n). N = wrapper_n- > or (_ n_i0_wrapper)-> get_raw_value () Wrapper_a = zcl_integer= > value_of (aa). Aa = wrapper_a- > shift_right ()-> get_raw_value (). Wrapper_b = zcl_integer= > value_of (bb). Bb = wrapper_b- > shift_right ()-> get_raw_value (). Cv_result = n. DATA (wrapper_i) = zcl_integer= > value_of (I). Wrapper_i- > shift_left (). I = wrapper_i- > get_raw_value (). ENDWHILE.ENDFORM.START-OF-SELECTION. DATA: i TYPE int4. Threshold = ipow (base = 2 exp = 30). PERFORM add USING a b CHANGING i. WRITE: / i.
The above content is how to use only bit operations to implement axib in ABAP. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.