bigint icon indicating copy to clipboard operation
bigint copied to clipboard

Cannot cast and/or pass bigint type inside [ ]

Open GothicChessInventor opened this issue 3 months ago • 1 comments

Using Visual Studio C/C++

Trying to compute large factorials and permutation for n-th lexograohic permutation of arrays/strings.

Code segment:

memmove(buffer, digits, length * sizeof(element_t));

for (i = 0; i < length - 1; i++)
{
    scale /= (permutation_t)(length - i);
    d = index / scale;
    index %= scale;
    z = to_bigint(0);
    if (d > z) 
    {
        bigger_i = to_bigint(i);
        c = buffer[d + bigger_i];
        memmove(buffer + i + 1, buffer + i, smaller_d * sizeof(element_t));
        buffer[i] = c;
    }
}

Fails inside c = buffer[] line of code.

Severity Code Description Project File Line Suppression State Error C2677 binary '[': no global operator found which takes type 'bigint' (or there is no acceptable conversion)

Top of code (compiles fine)

bigint permutation(element_t* const buffer, const element_t* const digits, const element_t length, bigint index) { element_t c; bigint d, z, scale, bigger_i; element_t smaller_d, i;

if (!buffer || !digits || length < 1)
    return errno = EINVAL;

...

Please advise.

GothicChessInventor avatar Apr 03 '24 18:04 GothicChessInventor