parity-common/README.md

39 lines
804 B
Markdown
Raw Normal View History

2016-12-22 03:07:45 -08:00
# bigint
2017-11-03 08:39:09 -07:00
[![Build Status](https://travis-ci.org/paritytech/primitives.svg?branch=master)](https://travis-ci.org/paritytech/primitives)
2017-06-21 20:23:26 -07:00
2016-12-22 03:07:45 -08:00
Fixed-sized integers arithmetic
2017-09-22 02:02:06 -07:00
To specify a dependency, add to `Cargo.toml`
2017-09-22 02:01:31 -07:00
2017-09-22 02:02:06 -07:00
```toml
2017-09-22 02:01:31 -07:00
[dependencies]
2017-11-03 08:41:41 -07:00
ethereum-types = "0.1"
2017-09-22 02:02:06 -07:00
```
2017-09-22 02:01:31 -07:00
Little example
2016-12-22 03:07:45 -08:00
```rust
2017-11-03 08:39:09 -07:00
extern crate ethereum_types;
use ethereum_types::U256;
2016-12-22 03:07:45 -08:00
fn main() {
2017-04-11 05:44:32 -07:00
let mut val: U256 = 1023.into();
for _ in 0..200 { val = val * 2.into() }
assert_eq!(
&format!("{}", val),
"1643897619276947051879427220465009342380213662639797070513307648"
);
2016-12-22 03:07:45 -08:00
}
2017-08-14 07:31:00 -07:00
```
2017-08-14 07:30:50 -07:00
### `no_std` crates
This crate has a feature, `std`, that is enabled by default. To use this crate
in a `no_std` context, add the following to your `Cargo.toml`:
```toml
[dependencies]
2017-11-03 08:39:09 -07:00
ethereum-types = { version = "4", default-features = false }
2017-08-14 07:30:50 -07:00
```