Is this a bug or a VERY sneaky case?

rempas rempas at tutanota.com
Sun Dec 26 06:34:14 UTC 2021


On Saturday, 25 December 2021 at 21:43:39 UTC, Rumbu wrote:
>
> It's common sense, log10 means "give me the power of 10 to 
> obtain n". And we know that 10^x means 1 followed by x zeroes, 
> hence the maximum width for the number. You add 1 because of 
> the 1 before the zeroes.
>
> So if we take as an example ubyte.max, we have ```log10(255) = 
> 2.4```. Truncated as int, you get ```2```. Add ```1``` and you 
> obtain ```3```, the exact length of ```255```.
>
> Or you can take 1000. ```log10(1000) = 3```, add ```1```, you 
> obtain ```4```, the exact length of ```1000```.
>
I got that now! You want to replace the static ifs for the enum 
"buffer_size" (which is a name I'm going to change). However, is 
the algorithm built-in? If I have to make it, this means that 
I'll have to spend time finding how to make it and I will also 
end up with more code I will eliminate. Unless of course there is 
still something I don't understand...


More information about the Digitalmars-d mailing list