c-smile / sciter-sdk

Sciter is an embeddable HTML/CSS/scripting engine
http://sciter.com
Other
2.11k stars 223 forks source link

Implement toFixed() for Float #179

Closed SonnyX closed 4 years ago

SonnyX commented 4 years ago

I just found out that sciter does not have a toFixed function, and only has String.printf("%.1f", download_progress) as a substitute. It might be nice to include a toFixed function in the future.

c-smile commented 4 years ago

It might be nice to include a toFixed function in the future.

Sure, just define it if you need that:

function Float.toFixed(frac) {
  return String.printf("%.*f", frac,this);
}

debug log: (3.1415).toFixed(2); // outputs "3.14"