Site Tools


Sidebar

Smart Card Solution

User Manual

JavaCard API Samples

Java Card Specification

Knowledge Sharing

javacard:jcvm:7.5.88_sdiv

7.5.88 sdiv

Divide short

Format

sdiv

Forms

sdiv = 71 (0x47)

Stack

…, value1, value2 → …, result

Description

Both value1 and value2 must be of type short. The values are popped from the operand stack. The short result is the value of the Java expression value1 / value2. The result is pushed onto the operand stack.

A short division rounds towards 0; that is, the quotient produced for short values in n/d is a short value q whose magnitude is as large as possible while satisfying | d · q | = | d | and n and d have the same sign, but q is negative when | n | >= | d | and n and d have opposite signs.

There is one special case that does not satisfy this rule: if the dividend is the negative integer of the largest possible magnitude for the short type, and the divisor is -1, then overflow occurs, and the result is equal to the dividend. Despite the overflow, no exception is thrown in this case.

Runtime Exception

If the value of the divisor in a short division is 0, sdiv throws an ArithmeticException.

javacard/jcvm/7.5.88_sdiv.txt · Last modified: 2017/05/13 04:10 (external edit)