chromium/third_party/blink/renderer/platform/wtf/decimal.cc

/*
 * Copyright (C) 2012 Google Inc. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 *
 *     * Redistributions of source code must retain the above copyright
 * notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above
 * copyright notice, this list of conditions and the following disclaimer
 * in the documentation and/or other materials provided with the
 * distribution.
 *     * Neither the name of Google Inc. nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/351564777): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "third_party/blink/renderer/platform/wtf/decimal.h"

#include <algorithm>
#include <cfloat>

#include "base/notreached.h"
#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
#include "third_party/blink/renderer/platform/wtf/math_extras.h"
#include "third_party/blink/renderer/platform/wtf/text/string_builder.h"

namespace blink {

namespace {

constexpr int kExponentMax =;
constexpr int kExponentMin =;
constexpr int kPrecision =;

constexpr uint64_t kMaxCoefficient =0xDE0B6B3A763FFFF);  // 999999999999999999 == 18 9's

// This class handles Decimal special values.
class SpecialValueHandler {};

SpecialValueHandler::SpecialValueHandler(const Decimal& lhs, const Decimal& rhs)
    :{}

SpecialValueHandler::HandleResult SpecialValueHandler::Handle() {}

Decimal SpecialValueHandler::Value() const {}

// This class is used for 128 bit unsigned integer arithmetic.
class UInt128 {};

UInt128& UInt128::operator/=(const uint32_t divisor) {}

// Returns high 64bit of 128bit product.
uint64_t UInt128::MultiplyHigh(uint64_t u, uint64_t v) {}

static int CountDigits(uint64_t x) {}

static uint64_t ScaleDown(uint64_t x, int n) {}

static uint64_t ScaleUp(uint64_t x, int n) {}

}  // namespace

Decimal::EncodedData::EncodedData(Sign sign, FormatClass format_class)
    :{}

Decimal::EncodedData::EncodedData(Sign sign, int exponent, uint64_t coefficient)
    :{}

bool Decimal::EncodedData::operator==(const EncodedData& another) const {}

Decimal::Decimal(int32_t i32)
    :{}

Decimal::Decimal(Sign sign, int exponent, uint64_t coefficient)
    :{}

Decimal::Decimal(const EncodedData& data) :{}

Decimal::Decimal(const Decimal& other) = default;

Decimal& Decimal::operator=(const Decimal& other) = default;

Decimal& Decimal::operator+=(const Decimal& other) {}

Decimal& Decimal::operator-=(const Decimal& other) {}

Decimal& Decimal::operator*=(const Decimal& other) {}

Decimal& Decimal::operator/=(const Decimal& other) {}

Decimal Decimal::operator-() const {}

Decimal Decimal::operator+(const Decimal& rhs) const {}

Decimal Decimal::operator-(const Decimal& rhs) const {}

Decimal Decimal::operator*(const Decimal& rhs) const {}

Decimal Decimal::operator/(const Decimal& rhs) const {}

bool Decimal::operator==(const Decimal& rhs) const {}

bool Decimal::operator!=(const Decimal& rhs) const {}

bool Decimal::operator<(const Decimal& rhs) const {}

bool Decimal::operator<=(const Decimal& rhs) const {}

bool Decimal::operator>(const Decimal& rhs) const {}

bool Decimal::operator>=(const Decimal& rhs) const {}

Decimal Decimal::Abs() const {}

Decimal::AlignedOperands Decimal::AlignOperands(const Decimal& lhs,
                                                const Decimal& rhs) {}

static bool IsMultiplePowersOfTen(uint64_t coefficient, int n) {}

// Round toward positive infinity.
Decimal Decimal::Ceil() const {}

Decimal Decimal::CompareTo(const Decimal& rhs) const {}

// Round toward negative infinity.
Decimal Decimal::Floor() const {}

Decimal Decimal::FromDouble(double double_value) {}

Decimal Decimal::FromString(const String& str) {}

Decimal Decimal::Infinity(const Sign sign) {}

Decimal Decimal::Nan() {}

Decimal Decimal::Remainder(const Decimal& rhs) const {}

Decimal Decimal::Round() const {}

double Decimal::ToDouble() const {}

String Decimal::ToString() const {}

Decimal Decimal::Zero(Sign sign) {}

std::ostream& operator<<(std::ostream& ostream, const Decimal& decimal) {}

}  // namespace blink