© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•16mo ago•
6 replies
daikirai

Get minimum bytes needed for a number in c#

I have this method in python that gives me the minimum bytes needed for a number
def get_time_byte_size(self, time):
        return (time.bit_length() + 7) // 8
def get_time_byte_size(self, time):
        return (time.bit_length() + 7) // 8


for a number like 122 it will return 1, and for like 257 it will return 2, so on and so forth
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

✅ Get bytes and append to List c#
C#CC# / help
16mo ago
✅ expierenced c# dev needed to create a programm u get payed
C#CC# / help
2y ago
✅ NullReferenceException for a array of bytes (image)
C#CC# / help
2y ago
C#/.NET WPF expert needed
C#CC# / help
4w ago