markus_ja 114 Report post Posted March 16, 2016 Hello, I need to round a float value to a fixed number of digits. Is such function already present in the RTL? e.g.: RoundTo(aValue: Float; aDigit: Integer) http://docwiki.embarcadero.com/Libraries/XE7/en/System.Math.RoundTo Share this post Link to post Share on other sites
warleyalex 417 Report post Posted March 16, 2016 the built-in javascript functions are located at Espruino.System unit, It would really handy if we had a kinda global Utils.pas, just to reference. { rounds a floating-point value to a specified digit } function RoundTo(x: float; digits: integer) : float; begin asm @Result=parseFloat((@x).toFixed(@digits)) end; end; Share this post Link to post Share on other sites
IgorSavkic 93 Report post Posted March 16, 2016 > the built-in javascript functions are located at Espruino.System unit, Isn't that just for Epruiono boards? Are all of those functions available in classical browsers? Share this post Link to post Share on other sites
CWBudde 160 Report post Posted March 18, 2016 the built-in javascript functions are located at Espruino.System unit,Isn't that just for Epruiono boards? Are all of those functions available in classical browsers? Yes, the units Espruino.* are solely for the Espruino board (software). It features a slightly limited subset of JavaScript and describes the API to access the hardware. Ideally, it should not contain other code. General code like the one that can be found in warleyalex post should go to System.* units or be covered by the underlying DWScript API. Unfortunately, it is not (yet) part of this, which means it must be added in the future. Until then, one can use what has been written above. Share this post Link to post Share on other sites