Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
flatbuffers
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
flatbuffers
Commits
ebcfbbad
Commit
ebcfbbad
authored
Feb 20, 2017
by
litianzhao
Committed by
Wouter van Oortmerssen
Feb 20, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix #4180: Long.prototype.toFloat64() overflow (#4182)
parent
6561c7a3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
5 deletions
+5
-5
flatbuffers.js
js/flatbuffers.js
+1
-1
JavaScriptTest.js
tests/JavaScriptTest.js
+4
-4
No files found.
js/flatbuffers.js
View file @
ebcfbbad
...
@@ -115,7 +115,7 @@ flatbuffers.Long.create = function(low, high) {
...
@@ -115,7 +115,7 @@ flatbuffers.Long.create = function(low, high) {
* @returns {number}
* @returns {number}
*/
*/
flatbuffers
.
Long
.
prototype
.
toFloat64
=
function
()
{
flatbuffers
.
Long
.
prototype
.
toFloat64
=
function
()
{
return
this
.
low
+
this
.
high
*
0x100000000
;
return
(
this
.
low
>>>
0
)
+
this
.
high
*
0x100000000
;
};
};
/**
/**
...
...
tests/JavaScriptTest.js
View file @
ebcfbbad
...
@@ -67,7 +67,7 @@ function main() {
...
@@ -67,7 +67,7 @@ function main() {
// Tests mutation first. This will verify that we did not trample any other
// Tests mutation first. This will verify that we did not trample any other
// part of the byte buffer.
// part of the byte buffer.
testMutation
(
fbb
.
dataBuffer
());
testMutation
(
fbb
.
dataBuffer
());
testBuffer
(
fbb
.
dataBuffer
());
testBuffer
(
fbb
.
dataBuffer
());
test64bit
();
test64bit
();
...
@@ -156,7 +156,8 @@ function test64bit() {
...
@@ -156,7 +156,8 @@ function test64bit() {
var
mon2
=
MyGame
.
Example
.
Monster
.
endMonster
(
fbb
);
var
mon2
=
MyGame
.
Example
.
Monster
.
endMonster
(
fbb
);
MyGame
.
Example
.
Stat
.
startStat
(
fbb
);
MyGame
.
Example
.
Stat
.
startStat
(
fbb
);
MyGame
.
Example
.
Stat
.
addVal
(
fbb
,
new
flatbuffers
.
Long
(
0x12345678
,
0x23456789
));
// 2541551405100253985 = 0x87654321(low part) + 0x23456789 * 0x100000000(high part);
MyGame
.
Example
.
Stat
.
addVal
(
fbb
,
new
flatbuffers
.
Long
(
0x87654321
,
0x23456789
));
// the low part is Uint32
var
stat
=
MyGame
.
Example
.
Stat
.
endStat
(
fbb
);
var
stat
=
MyGame
.
Example
.
Stat
.
endStat
(
fbb
);
MyGame
.
Example
.
Monster
.
startMonster
(
fbb
);
MyGame
.
Example
.
Monster
.
startMonster
(
fbb
);
...
@@ -177,8 +178,7 @@ function test64bit() {
...
@@ -177,8 +178,7 @@ function test64bit() {
var
stat
=
mon
.
testempty
();
var
stat
=
mon
.
testempty
();
assert
.
strictEqual
(
stat
!=
null
,
true
);
assert
.
strictEqual
(
stat
!=
null
,
true
);
assert
.
strictEqual
(
stat
.
val
()
!=
null
,
true
);
assert
.
strictEqual
(
stat
.
val
()
!=
null
,
true
);
assert
.
strictEqual
(
stat
.
val
().
low
,
0x12345678
);
assert
.
strictEqual
(
stat
.
val
().
toFloat64
(),
2541551405100253985
);
assert
.
strictEqual
(
stat
.
val
().
high
,
0x23456789
);
var
mon2
=
mon
.
enemy
();
var
mon2
=
mon
.
enemy
();
assert
.
strictEqual
(
mon2
!=
null
,
true
);
assert
.
strictEqual
(
mon2
!=
null
,
true
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment