LoginLogin

How do I make a decimal into a percent?

Root / Programming Questions / [.]

HTV04Created:
I used FORMAT to make a decimal into a percent, but I don’t know if I made my code too long. What’s the general way of making a decimal into a percent (without decimal places)?

FLOOR (I'm assuming you mean the # variable type to the % variable type)

It's hard to understand what you're talking about, but I guess you're talking about the # type (called "floating-point numbers", "real numbers", or simply "floats") and the % type (called "integers" or "ints"). I also assume you're talking about SB4, where the standard way to convert between these two types is with the INT and FLOAT functions. FLOOR actually returns a float, so if you really need the type to be an integer, you'll want to use INT instead.

Multiply a decimal by 100 and round it?

Oh... yeah, if you quite literally mean "percent" as in printing 0.237 as "24%", then yeah, just do ?ROUND(100*N);"%".

Oh... yeah, if you quite literally mean "percent" as in printing 0.237 as "24%", then yeah, just do ?ROUND(100*N);"%".
Thanks! Also I was talking about SB3 for one of the last projects I’m going to be working on for it.

Multiply a decimal by 100 and round it?
I had a brain fart and completely forgot about the ROUND command, lol.