Sha256: 94f9ab505e3321d4ff2fec8962bba90ec51f44df6a54c017f93efd250067be1a

Contents?: true

Size: 1.04 KB

Versions: 10

Compression:

Stored size: 1.04 KB

Contents

// Copyright 2011 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "src/diy-fp.h"

#include <stdint.h>

namespace v8 {
namespace internal {

void DiyFp::Multiply(const DiyFp& other) {
  // Simply "emulates" a 128 bit multiplication.
  // However: the resulting number only contains 64 bits. The least
  // significant 64 bits are only used for rounding the most significant 64
  // bits.
  const uint64_t kM32 = 0xFFFFFFFFu;
  uint64_t a = f_ >> 32;
  uint64_t b = f_ & kM32;
  uint64_t c = other.f_ >> 32;
  uint64_t d = other.f_ & kM32;
  uint64_t ac = a * c;
  uint64_t bc = b * c;
  uint64_t ad = a * d;
  uint64_t bd = b * d;
  uint64_t tmp = (bd >> 32) + (ad & kM32) + (bc & kM32);
  // By adding 1U << 31 to tmp we round the final result.
  // Halfway cases will be round up.
  tmp += 1U << 31;
  uint64_t result_f = ac + (ad >> 32) + (bc >> 32) + (tmp >> 32);
  e_ += other.e_ + 64;
  f_ = result_f;
}

}  // namespace internal
}  // namespace v8

Version data entries

10 entries across 9 versions & 2 rubygems

Version Path
libv8-6.0.286.54.1 vendor/v8/src/diy-fp.cc
libv8-6.0.286.54.0 vendor/v8/src/diy-fp.cc
libv8-6.0.286.54.0beta2 vendor/v8/src/diy-fp.cc
libv8-6.0.286.54.0beta1 vendor/v8/src/diy-fp.cc
libv8-6.0.286.44.0beta1 vendor/v8/src/diy-fp.cc
node-compiler-0.9.1 vendor/node/deps/v8/src/diy-fp.cc
node-compiler-0.9.0 vendor/node-v7.2.1/deps/v8/src/diy-fp.cc
node-compiler-0.8.0 vendor/node-v7.2.0/deps/v8/src/diy-fp.cc
node-compiler-0.7.0 vendor/node-v7.1.0/deps/v8/src/diy-fp.cc
node-compiler-0.7.0 vendor/node-v6.9.1/deps/v8/src/diy-fp.cc