1/* Copyright JS Foundation and other contributors, http://js.foundation
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#include "ecma-globals.h"
17#include "ecma-helpers.h"
18#include "ecma-number-arithmetic.h"
19
20/** \addtogroup ecma ECMA
21 * @{
22 *
23 * \addtogroup numberarithmetic ECMA number arithmetic operations
24 * @{
25 */
26
27/**
28 * ECMA-defined number remainder calculation.
29 *
30 * See also:
31 *          ECMA-262 v5, 11.5.3
32 *
33 * @return number - calculated remainder.
34 */
35ecma_number_t
36ecma_op_number_remainder (ecma_number_t left_num, /**< left operand */
37                          ecma_number_t right_num) /**< right operand */
38{
39  if (ecma_number_is_nan (left_num)
40      || ecma_number_is_nan (right_num)
41      || ecma_number_is_infinity (left_num)
42      || ecma_number_is_zero (right_num))
43  {
44    return ecma_number_make_nan ();
45  }
46  else if (ecma_number_is_infinity (right_num)
47           || (ecma_number_is_zero (left_num)
48               && !ecma_number_is_zero (right_num)))
49  {
50    return left_num;
51  }
52
53  return ecma_number_calc_remainder (left_num, right_num);
54} /* ecma_op_number_remainder */
55
56/**
57 * @}
58 * @}
59 */
60