diff --git a/libs/core/_locales/core-jsdoc-strings.json b/libs/core/_locales/core-jsdoc-strings.json index a273a4f5..27b36748 100644 --- a/libs/core/_locales/core-jsdoc-strings.json +++ b/libs/core/_locales/core-jsdoc-strings.json @@ -101,6 +101,16 @@ "Math": "More complex operations with numbers.", "Math.abs": "Returns the absolute value of a number (the value without regard to whether it is positive or negative).\nFor example, the absolute value of -5 is the same as the absolute value of 5.", "Math.abs|param|x": "A numeric expression for which the absolute value is needed.", + "Math.ceil": "Returns the smallest number greater than or equal to its numeric argument.", + "Math.ceil|param|x": "A numeric expression.", + "Math.floor": "Returns the greatest number less than or equal to its numeric argument.", + "Math.floor|param|x": "A numeric expression.", + "Math.idiv": "Returns the value of integer signed 32 bit division of two numbers.", + "Math.idiv|param|x": "The first number", + "Math.idiv|param|y": "The second number", + "Math.imul": "Returns the value of integer signed 32 bit multiplication of two numbers.", + "Math.imul|param|x": "The first number", + "Math.imul|param|y": "The second number", "Math.max": "Returns the larger of two supplied numeric expressions.", "Math.min": "Returns the smaller of two supplied numeric expressions.", "Math.pow": "Return the value of a base expression taken to a specified power.", @@ -109,10 +119,14 @@ "Math.random": "Return a pseudorandom number between 0 and `limit`.", "Math.randomBoolean": "Generates a `true` or `false` value randomly, just like flipping a coin.", "Math.random|param|limit": "the upper bound of the number generated, eg: 4", + "Math.round": "Returns a supplied numeric expression rounded to the nearest number.", + "Math.round|param|x": "The value to be rounded to the nearest number.", "Math.sign": "Returns the sign of the x, indicating whether x is positive, negative or zero.", "Math.sign|param|x": "The numeric expression to test", "Math.sqrt": "Return the square root of a number.", "Math.sqrt|param|x": "A numeric expression.", + "Math.trunc": "Returns the number with the decimal part truncated.", + "Math.trunc|param|x": "A numeric expression.", "Number.toString": "Return a string representation of a number.", "String": "Combine, split, and search text strings.\n\nCombine, split, and search text strings.", "String.charAt": "Return the character at the specified index.", @@ -356,7 +370,7 @@ "music.setTempo": "Sets the tempo to the specified amount", "music.setTempo|param|bpm": "The new tempo in beats per minute, eg: 120", "music.tempo": "Returns the tempo in beats per minute. Tempo is the speed (bpm = beats per minute) at which notes play. The larger the tempo value, the faster the notes will play.", - "parseInt": "Convert A string to an integer.", + "parseInt": "Convert a string to an integer.", "pins": "Control currents in Pins for analog/digital signals, servos, i2c, ...", "pins.analogPitch": "Emits a Pulse-width modulation (PWM) signal to the current pitch pin. Use `analog set pitch pin` to define the pitch pin.", "pins.analogPitch|param|frequency": "frequency to modulate in Hz.", diff --git a/libs/core/core.cpp b/libs/core/core.cpp index 2a026aa8..23860df0 100644 --- a/libs/core/core.cpp +++ b/libs/core/core.cpp @@ -165,6 +165,38 @@ namespace Math_ { { return ::sqrt(x); } + + // TODO: update signature when enabling FP + //% + int floor(int x){ + return x; + } + + //% + int ceil(int x){ + return x; + } + + //% + int trunc(int x){ + return x; + } + + //% + int round(int x){ + return x; + } + + //% + int imul(int x, int y) { + return x * y; + } + + //% + int idiv(int x, int y) { + return x / y; + } + } namespace Array_ {