aboutsummaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorDenton Liu <liu.denton+github@gmail.com>2016-05-12 03:31:02 +0800
committerDenton Liu <liu.denton+github@gmail.com>2016-05-18 23:23:47 +0800
commitbb62a8b3fd841cdf972cdfa77491f646a85099e5 (patch)
tree48b966f219652a14f047554762b7ddf828f43590 /docs
parent8bbe99ad1139b82df39207425d020aa8d8d51712 (diff)
downloaddexon-solidity-bb62a8b3fd841cdf972cdfa77491f646a85099e5.tar.gz
dexon-solidity-bb62a8b3fd841cdf972cdfa77491f646a85099e5.tar.zst
dexon-solidity-bb62a8b3fd841cdf972cdfa77491f646a85099e5.zip
Replaced all tabs with spaces
Diffstat (limited to 'docs')
-rw-r--r--docs/contracts.rst100
1 files changed, 50 insertions, 50 deletions
diff --git a/docs/contracts.rst b/docs/contracts.rst
index a9d7e167..ddfeb78c 100644
--- a/docs/contracts.rst
+++ b/docs/contracts.rst
@@ -836,56 +836,56 @@ custom types without the overhead of external function calls:
::
- library bigint {
- struct bigint {
- uint[] limbs;
- }
-
- function fromUint(uint x) internal returns (bigint r) {
- r.limbs = new uint[](1);
- r.limbs[0] = x;
- }
-
- function add(bigint _a, bigint _b) internal returns (bigint r) {
- r.limbs = new uint[](max(_a.limbs.length, _b.limbs.length));
- uint carry = 0;
- for (uint i = 0; i < r.limbs.length; ++i) {
- uint a = limb(_a, i);
- uint b = limb(_b, i);
- r.limbs[i] = a + b + carry;
- if (a + b < a || (a + b == uint(-1) && carry > 0))
- carry = 1;
- else
- carry = 0;
- }
- if (carry > 0) {
- // too bad, we have to add a limb
- uint[] memory newLimbs = new uint[](r.limbs.length + 1);
- for (i = 0; i < r.limbs.length; ++i)
- newLimbs[i] = r.limbs[i];
- newLimbs[i] = carry;
- r.limbs = newLimbs;
- }
- }
-
- function limb(bigint _a, uint _limb) internal returns (uint) {
- return _limb < _a.limbs.length ? _a.limbs[_limb] : 0;
- }
-
- function max(uint a, uint b) private returns (uint) {
- return a > b ? a : b;
- }
- }
-
-
- contract C {
- using bigint for bigint.bigint;
- function f() {
- var x = bigint.fromUint(7);
- var y = bigint.fromUint(uint(-1));
- var z = x.add(y);
- }
- }
+ library bigint {
+ struct bigint {
+ uint[] limbs;
+ }
+
+ function fromUint(uint x) internal returns (bigint r) {
+ r.limbs = new uint[](1);
+ r.limbs[0] = x;
+ }
+
+ function add(bigint _a, bigint _b) internal returns (bigint r) {
+ r.limbs = new uint[](max(_a.limbs.length, _b.limbs.length));
+ uint carry = 0;
+ for (uint i = 0; i < r.limbs.length; ++i) {
+ uint a = limb(_a, i);
+ uint b = limb(_b, i);
+ r.limbs[i] = a + b + carry;
+ if (a + b < a || (a + b == uint(-1) && carry > 0))
+ carry = 1;
+ else
+ carry = 0;
+ }
+ if (carry > 0) {
+ // too bad, we have to add a limb
+ uint[] memory newLimbs = new uint[](r.limbs.length + 1);
+ for (i = 0; i < r.limbs.length; ++i)
+ newLimbs[i] = r.limbs[i];
+ newLimbs[i] = carry;
+ r.limbs = newLimbs;
+ }
+ }
+
+ function limb(bigint _a, uint _limb) internal returns (uint) {
+ return _limb < _a.limbs.length ? _a.limbs[_limb] : 0;
+ }
+
+ function max(uint a, uint b) private returns (uint) {
+ return a > b ? a : b;
+ }
+ }
+
+
+ contract C {
+ using bigint for bigint.bigint;
+ function f() {
+ var x = bigint.fromUint(7);
+ var y = bigint.fromUint(uint(-1));
+ var z = x.add(y);
+ }
+ }
As the compiler cannot know where the library will be
deployed at, these addresses have to be filled into the