1

When doing this:

casperjs somescript.js --number=736280854938322517687376855643288785

and in the code:

var casper = require('casper').create();
var value = casper.cli.get("number");

console.log(value); // yields: 7.3628085493832246e+35
                    // want: 736280854938322517687376855643288785

I've looked and looked, pondered and hacked, but I'm not having much luck. The easy solution seems to be simply converting the number into a string. Or passing the number in as a string. But the syntax for this eludes me.

Artjom B.
  • 61,146
  • 24
  • 125
  • 222
CodeWriter
  • 337
  • 2
  • 7

1 Answers1

1

See Raw parameter values:

By default, the cli object will process every passed argument & cast them to the appropriate detected type[...]

You need to use casper.cli.raw.get("number") to get a non-parsed value. Since integer values that are bigger than 253 cannot be represented as an integer without losing precision, you would need to work with them as a string or use some big integer library (such as JSBN).

Community
  • 1
  • 1
Artjom B.
  • 61,146
  • 24
  • 125
  • 222