To perform exponentiation in Standard ML, you can use the Math.pow
function from the Real
structure. Here's an example:
32 chars2 lines
This will raise 2 to the power of 3 and store the result in the result
variable. Note that the arguments and the result are of type real
.
To round a real number up to the nearest integer (ceiling), you can use the Real.ceil
function. Here's an example:
29 chars2 lines
This will round 3.14 up to 4. The result will be of type real
.
In Ruby, you can achieve exponentiation using the **
operator. Here's an example:
main.rb16 chars2 lines
This will raise 2 to the power of 3 and store the result in the result
variable.
To find the ceiling of a number in Ruby, you can use the ceil
method from the Float
class. Here's an example:
main.rb19 chars2 lines
This will round the number 3.14 up to 4 and store the result in the result
variable.
gistlibby LogSnag