* The MIT License (MIT)
* Copyright (C) 2024 Huawei Device Co., Ltd.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*/
use napi::bindgen_prelude::*;
use napi_derive::napi;
#[napi]
fn bigint_add(a: BigInt, b: BigInt) -> u128 {
a.get_u128().1 + b.get_u128().1
}
#[napi]
fn create_big_int() -> BigInt {
BigInt {
words: vec![100u64, 200u64],
sign_bit: true,
}
}
#[napi]
fn create_big_int_i64() -> i64n {
i64n(100)
}
#[napi]
pub fn bigint_get_u64_as_string(bi: BigInt) -> String {
bi.get_u64().1.to_string()
}
#[napi]
pub fn bigint_from_i64() -> BigInt {
BigInt::from(100i64)
}
#[napi]
pub fn bigint_from_i128() -> BigInt {
BigInt::from(-100i128)
}