Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
fde8285
impl Deref for d128 (I *think* it's right)
Jun 22, 2017
0cfa23e
converts d128::from_raw_bytes to const fn
Jul 27, 2017
595257c
adds swp files to gitignore
Jul 27, 2017
a028505
adds "bytes" binary to easily extract the bytes for consts
Jul 27, 2017
22814bf
Merge remote-tracking branch 'upstream/master'
Aug 18, 2017
ca66543
disables gcc warnings that arrived with the new version of the gcc crate
Aug 18, 2017
c40dd70
adds decimal-macros plugin workspace and merges upstream v2.0.0 changes
Nov 8, 2017
7639aaf
fixes negative numbers bug for plugin
Nov 8, 2017
7899a2b
adds f64, f32 options to get_bytes
Nov 29, 2017
bc82f71
adds `d128::finite_or` and `d128::finite_or_else` modeled after `Opti…
Dec 20, 2017
b8418e2
Merge remote-tracking branch 'upstream/master' into v2.0.x
Dec 20, 2017
7f8335b
remove upstream shields/icons
Dec 20, 2017
f09bfe0
adds test feature/crate
Jan 12, 2018
82e9811
some benchmarks on generating random d128s from ints
Jan 12, 2018
ccf9fca
additional tests for some edge cases that came up
Jan 12, 2018
e49cfc2
impl<T> Sum<T> for d128 where T: Borrow<d128>
Jan 12, 2018
d762397
infinity, neg_infinity fns
Jan 12, 2018
09c9a56
Adds truncate, half-up rounding functions
Jan 30, 2018
3f4ec18
Merge remote-tracking branch 'jstrong/master' into v2.0.x
Jan 30, 2018
04f867e
adds d64, seems to be working
Jan 30, 2018
c981d29
adds simd benches
Jan 30, 2018
31221e8
bumps version to v2.1
Jan 30, 2018
2ca9d3f
changes some Into impls to From impls
Jan 31, 2018
d5878ab
impl From<d128> for u64
Jan 31, 2018
262b34d
version bump to v2.1.1
Jan 31, 2018
cf022aa
refinements to from<d128> for u64
Jan 31, 2018
9eaa727
impl From<u128> for d128
Jan 31, 2018
4e7e9cc
quiets a couple warnings
Feb 1, 2018
1b2409b
Adds (optional) impl of slog::Value for d128, d64
Mar 1, 2018
d05a254
version bump to v2.1.2
Mar 1, 2018
7b7f887
`impl From<d128> for d64`
Mar 9, 2018
4dc16bf
version bump to v2.1.3
Mar 9, 2018
015d676
`From<d128> for f64`, `From<d128> for f32`
Mar 28, 2018
950180a
removes now-stable i128_type from features
Mar 29, 2018
7bc83bb
safer f64, f32 conversion impls
Mar 30, 2018
5694efb
switches faster dep to point to git master; drops "simd-benchmarks" f…
jonathanstrong May 17, 2018
d4b2446
sets autobins=false to silence cargo warning about /bin
jonathanstrong May 17, 2018
921fb23
adds d128::from_f32_lossy(f32) -> d128, d128::from_f64_lossy(f64) -> …
jonathanstrong May 17, 2018
2127b9b
version bump to v2.1.4
jonathanstrong May 17, 2018
3ddad7a
minor cruft removal
May 26, 2018
ae73a76
underscore handling for d128! and d64!
jonathanstrong May 26, 2018
7365ac8
benchmarks for generating random d128 in range -1, 1
jonathanstrong May 26, 2018
c999333
ver bump to v2.1.5
jonathanstrong May 26, 2018
82c59f1
reorg binary location and add to-string binary
Jun 1, 2018
2f24319
documents a couple failed tries to remove exponential form
Jun 1, 2018
b820d5e
new bench for a scenario where you create a i64 key from a d128 price…
jonathanstrong Jun 23, 2018
3da849b
adds `as_bytes` alias to `to_raw_bytes`
jonathanstrong Jun 24, 2018
8fa94c0
removes trailing whitespace
jonathanstrong Aug 20, 2018
2c7b6a1
adds d128::finite_or_err<E>(self, err: E) -> Result<d128, E>
jonathanstrong Aug 28, 2018
3633eab
spent a while on this and it is NASTY
jonathanstrong Aug 29, 2018
d3f6d91
From<d128> for u128 (and more benches)
jonathanstrong Sep 20, 2018
b02b595
replaces d128! and d64! compiler plugins with proc macro replacements
jonathanstrong Oct 4, 2018
602bf53
Merge branch 'wip/plugin-fix' into v2.2.x
jonathanstrong Oct 4, 2018
68e521d
for posterity
jonathanstrong Oct 4, 2018
22384c2
fixes doctest to use decimal_macros d128!
jonathanstrong Oct 4, 2018
9fb7905
bump ver to v2.2.0
jonathanstrong Oct 4, 2018
6386e36
remove the old d128! and d64! macros
jonathanstrong Oct 4, 2018
d582517
itty bitty stuff
jonathanstrong Oct 4, 2018
359b987
proc_macro_hygiene switcharoo
jonathanstrong Oct 8, 2018
19f32bf
adds --round option to specify a precision
jonathanstrong Oct 24, 2018
fcbb11f
add note to deprecation notice for _lossy f64/f32 fns
jonathanstrong Dec 13, 2018
6bbead1
perf(d128): faster from_f64_lossy/from_f32_lossy (and removed depreca…
jonathanstrong Dec 13, 2018
65d62e6
bump ver to v2.2.1
jonathanstrong Dec 13, 2018
c80e875
style: minor changes from cargo fix --edition; upgrades to rust 2018
jonathanstrong Dec 13, 2018
743db5c
upgrades run-test to test d128 and d64 - fixes one problem w/ d64 and…
jonathanstrong Dec 13, 2018
d8d693c
edit clap app settings to allow negative numbers
jstrong-tios Apr 16, 2019
79970e7
make infinity and neg_infinity const fn
jstrong-tios Apr 16, 2019
c8b1b16
disable warnings
jstrong-tios Apr 16, 2019
9006f89
bump ber
jstrong-tios Apr 16, 2019
cc21d85
fix test version of d64! macro to remove underscores before parsing lit
jstrong-tios Jun 10, 2019
73992ec
add dyn for dynamic dispatch types
jstrong-tios Jun 10, 2019
7589bea
replace transmute calls with as_bytes
jstrong-tios Jun 10, 2019
061bea1
misc cleanup
jstrong-tios Jun 10, 2019
0ccf9f2
bump ver to v2.3.2
jstrong-tios Jun 10, 2019
88e2fc3
remove stuff that requires nightly
jonathanstrong Aug 20, 2019
be45f53
adds correct From<u64> and From<i64> for d64, though less than ideal
jonathanstrong Apr 25, 2020
9dace11
add a somewhat lame From<f64> for d128 impl
jonathanstrong Jun 4, 2020
9e7b016
Merge branch 'v2.3.x' of github.com:jonathanstrong/decimal into v2.3.x
jonathanstrong Jun 4, 2020
643e5ea
Revert "Merge branch 'v2.3.x' of github.com:jonathanstrong/decimal in…
jonathanstrong Jun 4, 2020
5c816c7
convert mem::uninitialized to mem::MaybeUninit
jonathanstrong Sep 30, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@
# Generated by Cargo
/target/
Cargo.lock
*.swp
*.swo
/decimal-macros/target/
38 changes: 29 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,29 +1,49 @@
[package]
name = "decimal"
version = "2.0.4"
authors = ["Alkis Evlogimenos <alkis@evlogimenos.com>"]
version = "2.4.0"
authors = ["Alkis Evlogimenos <alkis@evlogimenos.com>", "Jonathan Strong <jstrong@tioscapital.com>"]
build = "build.rs"
description = "Decimal floating point arithmetic for Rust"
repository = "https://github.com/alkis/decimal"
documentation = "https://alkis.github.io/decimal"
keywords = ["decimal", "decNumber"]
license = "Apache-2.0"
autobins = false
edition = "2018"

[badges]
travis-ci = { repository = "alkis/decimal" }
[lib]
name = "decimal"
path = "src/lib.rs"

[[bin]]
path = "src/bytes.rs"
name = "bytes"

[[bin]]
path = "src/to_string.rs"
name = "to-string"

[[bin]]
path = "src/run_test.rs"
name = "run-test"

[dependencies]
bitflags = "1"
libc = "0.2"
ord_subset = { optional = true, version = "3" }
rustc-serialize = { optional = true, version = "0.3" }
serde = { optional = true, version = "1" }
clap = { features = [], version = "2" }
faster = { git = "https://github.com/AdamNiederer/faster", branch = "master", optional = true }
slog = { version = "2", optional = true }
approx = "0.1"

[features]
default = ["ord_subset", "rustc-serialize", "serde"]
default = ["ord_subset", "serde", "slog"]

[build-dependencies]
cc = "1"

[dev-dependencies]
serde_json = "1"
rand = "0.4"
decimal-macros = { version = "0.2", path = "decimal-macros" }

[profile.test]
opt-level = 2
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# decimal

[![Travis](https://img.shields.io/travis/alkis/decimal.svg)](https://travis-ci.org/alkis/decimal)
![Downloads](https://img.shields.io/crates/d/decimal.svg)
[![Crates.io](https://img.shields.io/crates/v/decimal.svg)](https://crates.io/crates/decimal)
![Apache license](https://img.shields.io/crates/l/decimal.svg)

Decimal Floating Point arithmetic for rust based on the [decNumber
library](http://speleotrove.com/decimal/decnumber.html).

Expand Down
1 change: 1 addition & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ fn main() {
"0"
};
cc::Build::new()
.warnings(false)
.include("decNumber")
.file("decNumber/decContext.c")
.file("decNumber/decDouble.c")
Expand Down
10 changes: 10 additions & 0 deletions decNumber/decCommon.c
Original file line number Diff line number Diff line change
Expand Up @@ -1607,6 +1607,16 @@ char * decFloatToString(const decFloat *df, char *string){
pre=(Int)(c-cstart)+exp; // length+exp [c->LSD+1]
// [here, pre-exp is the digits count (==1 for zero)]

// if (exp>0) {
//
// if (exp>0 || pre<-7) {
//
// neither of the above variations worked during an attempt to
// remove exponential form entirely from this function. In both
// cases it ended up returning "0.00" for 1e-8
//
// - JS 6/1/18
//
if (exp>0 || pre<-5) { // need exponential form
e=pre-1; // calculate E value
pre=1; // assume one digit before '.'
Expand Down
17 changes: 17 additions & 0 deletions decimal-macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[package]
name = "decimal-macros"
version = "0.2.0"
authors = ["Callum Tolley <cgtrolley@gmail.com>"]

[lib]
name = "decimal_macros"
proc-macro = true

[dependencies]
decimal = { path = "../" }
libc = "~0.2"
quote = "0.6"
proc-macro2 = "0.4"

[build-dependencies]
gcc = "0.3"
43 changes: 43 additions & 0 deletions decimal-macros/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
extern crate decimal;
extern crate proc_macro;
#[macro_use]
extern crate quote;
extern crate proc_macro2;

use proc_macro::TokenStream;
use std::str::FromStr;

#[proc_macro]
pub fn d128(input: TokenStream) -> TokenStream {
let source = input.to_string();
let source = source.replace(" ", "");
let source = source.replace("_", "");

let d = match decimal::d128::from_str(&source[..]) {
Ok(d) => d,
Err(e) => panic!("Unexpected decimal format for {}: {:?}", source, e),
};
let bytes: [u8; 16] = d.as_bytes();
let iter = bytes.iter();
let expanded = quote! {
::decimal::d128::from_raw_bytes([ #(#iter,)* ])
};
expanded.into()
}

#[proc_macro]
pub fn d64(input: TokenStream) -> TokenStream {
let source = input.to_string();
let source = source.replace(" ", "");
let source = source.replace("_", "");
let d = match decimal::d64::from_str(&source[..]) {
Ok(d) => d,
Err(e) => panic!("Unexpected decimal format for {}: {:?}", source, e),
};
let bytes: [u8; 8] = d.as_bytes();
let iter = bytes.iter();
let expanded = quote! {
::decimal::d64::from_raw_bytes([ #(#iter,)* ])
};
expanded.into()
}
Loading