12 Replies
am i forced to create an entire base converter ?
Yeah looks like that only supports some specific bases. Take a look at https://stackoverflow.com/questions/923771/quickest-way-to-convert-a-base-10-number-to-any-base-in-net
Stack Overflow
Quickest way to convert a base 10 number to any base in .NET?
I have and old(ish) C# method I wrote that takes a number and converts it to any base:
string ConvertToBase(int number, char[] baseChars);
It's not all that super speedy and neat. Is there a good,
:catsweat:
Not hard to convert to/from any base by hand
https://github.com/Atulin/AnyBaseConverter/blob/master/AnyBaseConverter/AnyBaseConverter.cs
Yep, Convert.ToString only supports base 2, 8, 10, 16.
i'm not sure about this one, it uses while loop. i need a lot of performance so i would use the mathematic method
How do you, mathematically, convert between base 2 and base 10?
Without using a loop
i remember doing it at school but its only to base 10
you're right
I think using a List instead of a StringBuilder would be more efficient there:
That avoids having to constantly shuffle stuff around in the StringBuilder to make more room at the front
Could be, I'd have to benchmark it ig
alright this is the result
but because of performance issue my bot is very dumb