Skip to content

Commit

Permalink
添加一个处理int64的大数
Browse files Browse the repository at this point in the history
  • Loading branch information
Leo501 committed Nov 22, 2019
1 parent d68007f commit a22cdf6
Show file tree
Hide file tree
Showing 26 changed files with 23,155 additions and 0 deletions.
67 changes: 67 additions & 0 deletions BigNumber64Demo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#/////////////////////////////////////////////////////////////////////////////
# Fireball Projects
#/////////////////////////////////////////////////////////////////////////////

library/
temp/
local/
build/

#/////////////////////////////////////////////////////////////////////////////
# Logs and databases
#/////////////////////////////////////////////////////////////////////////////

*.log
*.sql
*.sqlite

#/////////////////////////////////////////////////////////////////////////////
# files for debugger
#/////////////////////////////////////////////////////////////////////////////

*.sln
*.csproj
*.pidb
*.unityproj
*.suo

#/////////////////////////////////////////////////////////////////////////////
# OS generated files
#/////////////////////////////////////////////////////////////////////////////

.DS_Store
ehthumbs.db
Thumbs.db

#/////////////////////////////////////////////////////////////////////////////
# exvim files
#/////////////////////////////////////////////////////////////////////////////

*UnityVS.meta
*.err
*.err.meta
*.exvim
*.exvim.meta
*.vimentry
*.vimentry.meta
*.vimproject
*.vimproject.meta
.vimfiles.*/
.exvim.*/
quick_gen_project_*_autogen.bat
quick_gen_project_*_autogen.bat.meta
quick_gen_project_*_autogen.sh
quick_gen_project_*_autogen.sh.meta
.exvim.app

#/////////////////////////////////////////////////////////////////////////////
# webstorm files
#/////////////////////////////////////////////////////////////////////////////

.idea/

#//////////////////////////
# VS Code
#//////////////////////////

.vscode/
37 changes: 37 additions & 0 deletions BigNumber64Demo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# BigNumber64Demo
> 介绍如何在 javascript 处理64位大数。
### 方案1
[long.js](https://github.com/dcodeIO/long.js)
##### 介绍
A Long class for representing a 64 bit two's-complement integer value derived from the Closure Library for stand-alone use and extended with unsigned support.

##### 简单使用
~~~
var Long = require("long");
var longVal = new Long(0xFFFFFFFF, 0x7FFFFFFF);
console.log(longVal.toString());
~~~

##### 优势
* 可以把服务器发过来的高位、底位数据合成一个大数。显示,+、-、*、/、。

### 方案2
[bignumber.js](https://github.com/alexbardas/bignumber.js)
##### 介绍
BigNumber.js is a light javascript library for node.js and the browser. It supports arithmetic operations on Big Integers.

It is build with performance in mind, uses the fastest algorithms and supports all basic arithmetic operations (+, -, *, /, %, ^, abs). Works with both positive and negative big integers.

##### 简单介绍
~~~
var BigNumber = require('big-number');
BigNumber(5).plus(97).minus(53).plus(434).multiply(5435423).add(321453).multiply(21).div(2).pow(2);
// 760056543044267246001
~~~

##### 优势
* 支持add/plus, minus/subtract, multiply/mult, divide/div, power/pow, mod, equals, lt, lte, gt, gte, isZero, abs

6 changes: 6 additions & 0 deletions BigNumber64Demo/assets/Scene.meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"ver": "1.0.1",
"uuid": "29f52784-2fca-467b-92e7-8fd9ef8c57b7",
"isGroup": false,
"subMetas": {}
}
Loading

0 comments on commit a22cdf6

Please sign in to comment.