Microsoft MakeCode

How to limit decimal places when using Show Number with a float?

I’m trying to display a floating point value on the micro:bit’s screen. When I use the Show Number block after performing a division operation (e.g. (analog read pin P0) x 3 / 1023 ), the screen scrolls something like 12 decimal places. Is there a way I can round or truncate the decimal places to something more reasonable (e.g. 2 places)?

Hummm… I taught we did this automatically. What is your code?

This is what I’m using:

Can you report a bug in pxt microbit github and at mention me? Thanks.


It looks like some other people are having a similar issue…feel free to mark as duplicate.