tmp_sc Posted November 8, 2023 Report Share Posted November 8, 2023 Hi, I want to set the value of `sc_biguint<128>` with `get_raw` method. If the value is just initialized to 0, I cannot do it. E.g. sc_biguint<128> val{0x00}; cout << hex << val << endl; auto* ptr = val.get_raw(); *ptr = 0x2AAABBBB; cout << hex << val << endl; output is 000000000000000000000000000000000 000000000000000000000000000000000 but in case it had some arithmetic operations, I can. E.g. sc_biguint<128> val{0x00}; val += 0xABCDEF0912345678; <--- difference cout << hex << val << endl; auto* ptr = val.get_raw(); *ptr = 0x2AAABBBB; cout << hex << val << endl; and the output is 00000000000000000abcdef0912345678 00000000000000000abcdef092aaabbbb <--- value is changed Any idea what is the reason for this feature? Quote Link to comment Share on other sites More sharing options...
tmp_sc Posted November 14, 2023 Author Report Share Posted November 14, 2023 In the meantime I figured out: Setting sc_biguint via get_raw pointer is not visible immediately because sc_uint (base class for sc_biguint) has several members. In this case most important ones are private: small_type sgn; // Shortened as s. ... sc_digit *digit; // Shortened as d. if we access through get_raw method sc_digit* get_raw() const { return digit; } we will update only digit, but not sgn . In case we want to print out the value of sc_biguint, at some moment we will call bool sc_unsigned::iszero() const { if (sgn == SC_ZERO) return true; So without updating the sgn, we will get the value 0 even though digit is changed Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.