All Projects → alianse777 → solidity-standard-library

alianse777 / solidity-standard-library

Licence: other
Solidity standard library (Array, random, math, string)

Projects that are alternatives of or similar to solidity-standard-library

InterviewBit
Collection of solution for problems on InterviewBit
Stars: ✭ 77 (+26.23%)
Mutual labels:  strings, maths
BackportCpp
Library of backported modern C++ types to work with C++11
Stars: ✭ 53 (-13.11%)
Mutual labels:  standard-library
Stringy
A PHP string manipulation library with multibyte support
Stars: ✭ 2,461 (+3934.43%)
Mutual labels:  strings
envs
Easy access of environment variables from Python with support for typing (ex. booleans, strings, lists, tuples, integers, floats, and dicts). Now with CLI settings file converter.
Stars: ✭ 25 (-59.02%)
Mutual labels:  strings
Stringsimilarity.net
A .NET port of java-string-similarity
Stars: ✭ 242 (+296.72%)
Mutual labels:  strings
LeetCode
Solution to LeetCode Problems in Python and Golang 🎯
Stars: ✭ 12 (-80.33%)
Mutual labels:  strings
Util
A collection of useful utility functions
Stars: ✭ 201 (+229.51%)
Mutual labels:  strings
abacus
📐 C# cross precision 3D maths library.
Stars: ✭ 35 (-42.62%)
Mutual labels:  maths
hope
A quest for a "standard" Erlang library with uniform, composable abstractions.
Stars: ✭ 18 (-70.49%)
Mutual labels:  standard-library
Algorithm-Implementation
This is our effort to collect the best implementations to tough algorithms. All codes are written in c++.
Stars: ✭ 16 (-73.77%)
Mutual labels:  strings
slice
A JavaScript implementation of Python's negative indexing and extended slice syntax.
Stars: ✭ 53 (-13.11%)
Mutual labels:  strings
CBioInfCpp-0-
The lib CBioInfCpp.h contains 3 groups of functions for C++: "Input-Output", "Working with strings", "Working with graphs". Data structures "Adjacency vector" and "Adjacency map" are implemented in the last one (i.e. in "Working with graphs"). See About_CBioInfCpp for details.
Stars: ✭ 12 (-80.33%)
Mutual labels:  strings
graphPlayground
Create graphs by adding your vertices and edges and see them react!! 🎨
Stars: ✭ 32 (-47.54%)
Mutual labels:  maths
Quiz
Ex 1 - Run timed quizzes via the command line
Stars: ✭ 234 (+283.61%)
Mutual labels:  strings
FixedPointsArduino
A fixed point arithmetic library for Arduino
Stars: ✭ 68 (+11.48%)
Mutual labels:  maths
Goutil
💪 Helper Utils For The Go: string, array/slice, map, format, cli, env, filesystem, test and more. Go 的一些工具函数,格式化,特殊处理,常用信息获取等等
Stars: ✭ 205 (+236.07%)
Mutual labels:  strings
algoexpert
AlgoExpert is an online platform that helps software engineers to prepare for coding and technical interviews.
Stars: ✭ 8 (-86.89%)
Mutual labels:  strings
HLML
Auto-generated maths library for C and C++ based on HLSL/Cg
Stars: ✭ 23 (-62.3%)
Mutual labels:  maths
stdgems
Ruby's default & bundled gems: The new standard library
Stars: ✭ 94 (+54.1%)
Mutual labels:  standard-library
pendfetch
Double Pendulum visualised with fetching system information in Python.
Stars: ✭ 62 (+1.64%)
Mutual labels:  maths

Quick overview of the library

Array.sol

Storage array wrapper.

UintArray contract members:

  • UintArray(uint[] data) - construct new array contract
  • min() - returns minimal array element
  • max() - returns maximal array element
  • sum() - returns sum of all array elements
  • set(uint[] arr) - assign array
  • get() - returns stored array
  • sort() - sorts all array elements

IntArray contract members:

  • IntArray(int[] data) - construct new array contract
  • min() - returns minimal array element
  • max() - returns maximal array element
  • sum() - returns sum of all array elements
  • set(int[] arr) - assign array
  • get() - returns stored array
  • sort() - sorts all array elements

Convert.sol

Helper contract to convert strings or ints/uints.

Converter contract members:

  • toString(uint x) - converts uint to string
  • toUint(string str) - converts string to uint

Math.sol

Basic mathematical functions.

Math contract members:

  • sqrt(uint x) - computes square root of x
  • mexp(uint x, uint k, uint m) - computes (pow(x, k)) mod m

Memory.sol

WARNING: These functions are used to perform low-level memory access and may cause security risk when used improperly.

STDMemory contract members:

  • m_ref_uint(uint[] arr) - returns address of arr
  • m_unref_uint(uint ptr) - returns array pointed by ptr
  • m_ref_int(int[] arr) - returns address of arr
  • m_unref_int(uint ptr) - returns array pointed by ptr

Multiprecision.sol

Floating point calculations. Note: double_t(1, 5) will be 1.05 but double_t(1, 50) will be 1.5 with dscale = 2 (Number of digits after dot)

Example:

   import "multiprecision.sol";
   contract Test is Double
   {
       function test() internal
       {
           double memory a = double_t(1, 20); // 1.20
           double memory b = double_t(0, 2); // 0.02
           double memory result = double_add(a, b); // 1.22
           
           a = double_t(2, 0); // 2.00
           b = double_t(1, 0); // 1.00
           a.sign = true; // -2.00
           result = double_add(a, b); // -2.00 + 1.00 = -1.00
           
           result = double_sub(a, b); // -2.00 - 1.00 = -3.00
           result = double_mult(a, b); // -2.00 * 1.00 = -2.00
           result = double_div(a, b); // -2.00 / 1.00 = -2.00
           
           dscale = 3; // change precision (.00 -> .000)
           double_t(1, 5); // now 1.005
           double_t(1, 50); // now 1.050
           double_t(1, 500); // now 1.500
       }
  }

Double contract members:

  • struct double - signed double representation
  • double_t(int integral, uint fractional) - creates a new double as integral.fractional
  • double_add(double a, double b) - a + b
  • double_sub(double a, double b) - a - b
  • double_mult(double a, double b) - a×b
  • double_div(double a, double b) - a / b
  • double_lt(double a, double b) - a < b
  • double_le(double a, double b) - a <= b
  • double_eq(double a, double b) - a == b
  • double_ge(double a, double b) - a >= b
  • double_gt(double a, double b) - a > b

Random.sol

Random number generator based on SHA3 function (not cryptographicaly secure)

Random contract members

  • rand(uint seed) - returns random unsigned int generated wuth seed
  • randint() - returns random unsigned int
  • randbytes(uint size, uint seed) - returns array of random bytes
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].