Skip to content

Commit

Permalink
Updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
wisbery committed Mar 22, 2024
1 parent dfdb299 commit 414b48e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dfp-number-sys"
version = "0.1.0"
version = "0.0.20"
authors = ["Dariusz Depta <[email protected]>"]
description = "Rust bindings for Intel® Decimal Floating-Point Math Library"
documentation = "https://docs.rs/dfp-number-sys"
Expand Down
11 changes: 7 additions & 4 deletions src/bid128_000.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ pub const BID128_MINUS_BILLION: BID128 = BID128 {
//======================================================================================================================

extern "C" {
fn __bid128_abs(x: BID128) -> BID128;
fn __bid128_abs(x: BID128, flags: *mut c_uint) -> BID128;
fn __bid128_acos(x: BID128, round: c_uint, flags: *mut c_uint) -> BID128;
fn __bid128_add(x: BID128, y: BID128, round: c_uint, flags: *mut c_uint) -> BID128;
fn __bid128_copy(x: BID128) -> BID128;
Expand Down Expand Up @@ -212,13 +212,16 @@ extern "C" {
///
/// ```
/// use dfp_number_sys::bid128_000::*;
/// use dfp_number_sys::FB_CLEAR;
///
/// let x = bid128_from_int32(-2);
/// let y = bid128_abs(x);
/// let mut flags = FB_CLEAR;
/// let y = bid128_abs(x, &mut flags);
/// assert_eq!("+2E+0", bid128_quiet_to_string(y));
/// assert_eq!(flags, FB_CLEAR);
/// ```
pub fn bid128_abs(x: BID128) -> BID128 {
unsafe { __bid128_abs(x) }
pub fn bid128_abs(x: BID128, flags: &mut u32) -> BID128 {
unsafe { __bid128_abs(x, flags) }
}

pub fn bid128_acos(x: BID128, round: u32, flags: &mut u32) -> BID128 {
Expand Down
8 changes: 6 additions & 2 deletions tests/bid128_000/bid128_abs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ use dfp_number_sys::bid128_000::*;

#[test]
fn _0001() {
eq("+2E+0", bid128_abs(bid128_from_int32(2)));
let mut flags = FB_CLEAR;
eq("+2E+0", bid128_abs(d128("2"), &mut flags));
assert_eq!(flags, FB_CLEAR);
}

#[test]
fn _0002() {
eq("+2E+0", bid128_abs(bid128_from_int32(-2)));
let mut flags = FB_CLEAR;
eq("+2E+0", bid128_abs(d128("-2"), &mut flags));
assert_eq!(flags, FB_CLEAR);
}

0 comments on commit 414b48e

Please sign in to comment.