// Copyright 2026 International Digital Economy Academy
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

///|
/// High Precision Decimal structure for "Simple Decimal Conversion" algorithm.
/// Developed by Ken. Thompson, Russ Cox, Robert Griesemer, Nigel Tao.
///
/// reference:
/// - 
/// - 
#deprecated("use `@string.parse_double` instead", skip_current_package=true)
struct Decimal {
  digits : FixedArray[Byte]
  mut digits_num : Int
  mut decimal_point : Int
  mut negative : Bool
  mut truncated : Bool
  mut overflowed : Int
} derive(@debug.Debug)

///|
/// Create a zero decimal.
#deprecated("use `@string.parse_double` instead", skip_current_package=true)
pub fn Decimal::new() -> Decimal {
  Decimal::new_priv()
}

///|
/// Create a decimal with an Int64 value.
#deprecated("use `@string.parse_double` instead", skip_current_package=true)
pub fn Decimal::from_int64(v : Int64) -> Decimal {
  Decimal::from_int64_priv(v)
}

///|
/// Function `parse_decimal`.
#deprecated("use `@string.parse_double` instead", skip_current_package=true)
pub fn parse_decimal(str : StringView) -> Decimal raise StrConvError {
  parse_decimal_from_view(str)
}

///|
/// Function `parse_decimal`.
#deprecated("use `@string.parse_double` instead", skip_current_package=true)
pub fn Decimal::parse_decimal(str : StringView) -> Decimal raise StrConvError {
  parse_decimal_from_view(str)
}

///|
/// Convert the decimal to Double.
#deprecated("use `@string.parse_double` instead", skip_current_package=true)
pub fn Decimal::to_double(self : Decimal) -> Double raise StrConvError {
  self.to_double_priv()
}

///|
/// Binary shift left (s > 0) or right (s < 0).
/// The shift count must not larger than the max_shift to avoid overflow.
#deprecated("use `@string.parse_double` instead", skip_current_package=true)
pub fn Decimal::shift(self : Decimal, s : Int) -> Unit {
  self.shift_priv(s)
}

///|
/// Parse input into this package's structured value.
#deprecated("use `@string.from_str` instead", skip_current_package=true)
pub fn[A : FromStr] parse(str : StringView) -> A raise StrConvError {
  A::from_str(str)
}