AnsweredAssumed Answered

How to handle big integer in JavaScript

Question asked by Ram2010mech on May 10, 2017
Latest reply on May 12, 2017 by Ram2010mech

Hi All,

 

I need to handle big number using JavaScripts (70200000000000005355) but when am executing am getting the below error.

long Number = 70200000000000005355;

Can you please help.

 

============================================================================
| Error in Script
============================================================================
| Step: Write to an Excel
----------------------------------------------------------------------------
| Message: Parse error at line 19, column 15 : Number too big for integer type: 70200000000000005355
----------------------------------------------------------------------------
| Trapped Exception: Parse error at line 19, column 15 : Number too big for integer type: 70200000000000005355
| Trapped Message: bsh.ParseException: Parse error at line 19, column 15 : Number too big for integer type: 70200000000000005355
----------------------------------------------------------------------------
STACK TRACE
bsh.ParseException: Parse error at line 19, column 15 : Number too big for integer type: 70200000000000005355
at bsh.Parser.createParseException(Parser.java:129)
at bsh.Parser.Literal(Parser.java:2307)
at bsh.Parser.PrimaryPrefix(Parser.java:2171)
at bsh.Parser.PrimaryExpression(Parser.java:2093)
at bsh.Parser.PostfixExpression(Parser.java:2030)
at bsh.Parser.UnaryExpressionNotPlusMinus(Parser.java:1913)
at bsh.Parser.UnaryExpression(Parser.java:1805)
at bsh.Parser.MultiplicativeExpression(Parser.java:1699)
at bsh.Parser.AdditiveExpression(Parser.java:1656)
at bsh.Parser.ShiftExpression(Parser.java:1597)
at bsh.Parser.RelationalExpression(Parser.java:1530)
at bsh.Parser.InstanceOfExpression(Parser.java:1502)
at bsh.Parser.EqualityExpression(Parser.java:1459)
at bsh.Parser.AndExpression(Parser.java:1416)
at bsh.Parser.ExclusiveOrExpression(Parser.java:1384)
at bsh.Parser.InclusiveOrExpression(Parser.java:1341)
at bsh.Parser.ConditionalAndExpression(Parser.java:1298)
at bsh.Parser.ConditionalOrExpression(Parser.java:1255)
at bsh.Parser.ConditionalExpression(Parser.java:1215)
at bsh.Parser.Expression(Parser.java:1115)
at bsh.Parser.VariableInitializer(Parser.java:624)
at bsh.Parser.VariableDeclarator(Parser.java:552)
at bsh.Parser.TypedVariableDeclaration(Parser.java:3359)
at bsh.Parser.BlockStatement(Parser.java:2809)
at bsh.Parser.Line(Parser.java:200)
at bsh.Interpreter.Line(Interpreter.java:1014)
at bsh.Interpreter.eval(Interpreter.java:651)
at bsh.Interpreter.eval(Interpreter.java:758)
at bsh.Interpreter.eval(Interpreter.java:747)
at com.itko.lisa.test.ScriptExecHandler.executeScript(ScriptExecHandler.java:636)
at com.itko.lisa.test.ScriptExecHandler.executeScriptOld(ScriptExecHandler.java:528)
at com.itko.lisa.test.ScriptNode._execute(ScriptNode.java:126)
at com.itko.lisa.editor.ScriptNodeEditor.execute(ScriptNodeEditor.java:100)
at com.itko.lisa.editor.ScriptNodeEditor.access$000(ScriptNodeEditor.java:42)
at com.itko.lisa.editor.ScriptNodeEditor$1.actionPerformed(ScriptNodeEditor.java:61)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.NumberFormatException: Number too big for integer type: 70200000000000005355
at bsh.Parser.parseInt(Parser.java:150)
at bsh.Parser.Literal(Parser.java:2305)
... 69 more
============================================================================

 

Thanks

Ram

Outcomes