## How do you find the rightmost digit of an integer?

x % 10 looks like the correct answer. But is not. -2 % 10 is either -2 or 8 depending on language/implementation/whatever. And neither is actually “last digit”. So the correct answer is abs(x) % 10.

## Lua replacement for the % operator

It’s not ideal, but according to the Lua 5.2 Reference Manual: a % b == a – math.floor(a/b)*b

## How to round a number to significant figures in Python

You can use negative numbers to round integers: Thus if you need only most significant digit: You’ll probably have to take care of turning float to integer if it’s bigger than 1.

## Clamping floating numbers in Python?

There’s no such function, but will do the trick.

## How to perform an integer division, and separately get the remainder, in JavaScript?

For some number y and some divisor x compute the quotient (quotient) and remainder (remainder) as:

## How to perform an integer division, and separately get the remainder, in JavaScript?

For some number y and some divisor x compute the quotient (quotient) and remainder (remainder) as:

## What does != do/mean in python

!= means “not equal to” and is a logical comparison. Break down the logical expression here:

## JavaScript exponents

There is an exponentiation operator, which is part of the ES7 final specification. It is supposed to work in a similar manner with python and matlab: Now it is already implemented in Edge14, Chrome52, and also it is available with traceur or babel.

## Java Round up Any Number

Math.ceil() is the correct function to call. I’m guessing a is an int, which would make a / 100 perform integer arithmetic. Try Math.ceil(a / 100.0) instead. Outputs:

## Calculating a 2D Vector’s Cross Product

Implementation 1 returns the magnitude of the vector that would result from a regular 3D cross product of the input vectors, taking their Z values implicitly as 0 (i.e. treating the 2D space as a plane in the 3D space). The 3D cross product will be perpendicular to that plane, and thus have 0 X …