javascript - angular.js parsing integer incorrectly -



javascript - angular.js parsing integer incorrectly -

i'm using angular create ajax phone call own rest api.

$scope.authenticate = function() { $http({ headers: httpheaders, url: '/something/', method: "post", data: { 'userid' : $scope.userid, 'password': $scope.password }, cache: false }) .success(function(response, status) { console.log(response); var ourstring = json.stringify(response); console.log(ourstring); $scope.authenticate_data = response; $scope.sessionid = response.sessionid; $scope.cookie = response.cookie; $scope.message = "you have authenticated." }); }

somehow, angular incorrectly parses integers, , in chrome inspector's network tab, phone call shows following:

request tab

{"sessionid": 115053508782199126, "cookie": "jsessionid=e61dd3443ae9e119060a637cf039936b; path=/webservice"}

preview tab (value stored in scope)

{"sessionid":115053508782199120,"cookie":"jsessionid=e61dd3443ae9e119060a637cf039936b; path=/webservice"}

when wrap integer string in backend, fine. however, want understand causing error.

related link: angular $resource not parse correctly integer response

there no such thing purely integer variable in javascript.

instead, have numbers, stored ieee754 floating-point values. , the ecmascript standard, have:

note positive , negative integers magnitude no greater 2^53 representable in number type (indeed, integer 0 has 2 representations, +0 , −0).

note not mean largest integer representable in javascript 2^53, rather 1 time larger this, integers can represented. 1 time you've exhausted 53-bit mantissa of ieee754 floating point representation, there start appear gaps between integers.

your illustration session id 115053508782199126 rather larger 2^53, , turns out closest integer floating-point value 115053508782199120. so, need utilize strings.

javascript angularjs

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -