Skip to content

[question] Porting from boost multiprecision  #234

@illera88

Description

@illera88

Hi,

I'm thinking on creating a branch to move away from boost in Triton. I have multiple questions:

  • Casting one type to another should be as easy to use static_cast<T>(value) right? i.e.
this->memory[addr+i] = (cv & 0xff).convert_to<triton::uint8>(); // old
this->memory[addr+i] = static_cast<triton::uint8>((cv & 0xff)); //new
  • How can I cast a number to string? Is the following correct?
math::wide_integer::uint512_t value = <whatever>;           
std::stringstream ss;
ss << value;
std::string strValue(ss.str());
  • How can I cast from a std::string to a math::wide_integer::uint512_t?
  • How can I create a wide integer whose size is 80 bits? This is the code I want to replicate. I've tried the follwing:
typedef math::wide_integer::uintwide_t<static_cast<size_t>(UINT32_C(80)), std::uint32_t> uint80;

but I get:

error C2338:  Error: Width2 must be 2^n times 1...63 (with n >= 3), while being 16, 24, 32 or larger, and exactly divisible by limb count

because of:

// Verify that the Width2 template parameter (mirrored with my_width2):
    //   * Is equal to 2^n times 1...63.
    //   * And that there are at least 16, 24 or 32 binary digits, or more.
    //   * And that the number of binary digits is an exact multiple of the number of limbs.
    static_assert(   (detail::verify_power_of_two_times_granularity_one_sixty_fourth<my_width2>::conditional_value)
                  && (my_width2 >= 16U) // NOLINT(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)
                  && (my_width2 == (number_of_limbs * static_cast<size_t>(std::numeric_limits<limb_type>::digits))),
                  "Error: Width2 must be 2^n times 1...63 (with n >= 3), while being 16, 24, 32 or larger, and exactly divisible by limb count");

Thank you so much for your help

Metadata

Metadata

Assignees

Labels

questionFurther information is requested

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions