How to: left justify numbers & determine number of digits in a number

Hi Hops, here’s how to make left justified numbers for your project so numbers like scores stay aligned to the corresponding labels even when numbers get really big. You need to know the number of digits in the number, so that’s also shown.

The basic idea is straightforward. Offset the position of the number by:
11 x size/100 x (number of digits - 1)

Here’s the code:

And an example:
https://c.gethopscotch.com/p/yspsioswh

16 Likes

This is really cool!! I’m sure this will help a lot of people :<I’m sure>D

2 Likes

This is really cool, thank you for sharing!

2 Likes

Coolness that’s pretty cool thank you for that.

2 Likes