❔ Implementing shifts for 256 bit integer class
I'm writing a custom 256 bit int class for Godot. Internally it is stored as 4
ulong
types. I've tried the following implementation but it has odd bugs such as shifts working for some numbers, but not all: 2 Replies
it should be a struct not a class
also use stackalloc for those temporary arrays
well your code is just wrong
it doesn't handle shift of more than 64 bits
also take a byte instead of an int, or do a range check
shifting by an amount larger than the size of a number is UB I think
ah nevermind it does handle larger values
well, must be some logical error
ah I see it
divide by 64 not by 256
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.