Giter Club home page Giter Club logo

extprim's Introduction

extprim

Travis (Linux and OS X) Build status AppVeyor (Windows) Build status Coverage Status crates.io MIT / Apache 2.0

Thanks to RFC 1504 “int128”, you can use i128 and u128 directly on nightly Rust starting from 1.16. Using the built-in types are preferred.

Extra primitive types for stable Rust. Currently includes:

  • u128 (unsigned 128-bit integers)
  • i128 (signed 128-bit integers)

Documentation

You may also find other primitive types in other crates:

Usage

# Cargo.toml
[dependencies]
extprim = "1.3"

If you want to use the u128!() and i128!() macros, please include the extprim_literals plugin.

# Cargo.toml
[dependencies]
extprim = "1.3"
extprim_literals = "2.0"

Example

#[macro_use] extern crate extprim_literals;
extern crate extprim;

use std::str::FromStr;
use extprim::i128::i128;

fn main() {
    let a = i128::from_str("100000000000000000000000000000000000000").unwrap();
            // convert string to u128 or i128
    let b = i128::new(10).pow(38);
            // 64-bit integers can be directly new'ed
    assert_eq!(a, b);

    let c = i128::from_parts(5421010862427522170, 687399551400673280);
            // represent using the higher- and lower-64-bit parts
    let d = c - a;
            // standard operators like +, -, *, /, %, etc. work as expected.
    assert_eq!(d, i128::zero());

    const e: i128 = i128!(100000000000000000000000000000000000000);
            // use the literal macros
    assert_eq!(a, e);
}

extprim's People

Contributors

kennytm avatar pmarks avatar ksari avatar hcpl avatar

Watchers

James Cloos avatar Igor Raits avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.