BigInteger in JavaScript mode

ch3ch3
edited November 2015 in JavaScript Mode

Has anyone used it successfully in processing.js? I get [ReferenceError: BigInteger is not defined]

import java.math.BigInteger;


void setup ()
{
  size( 800, 600 );
  colorMode(RGB,1);
  background(0);

  text("Hello World!", 50, 50);
  BigInteger b = new BigInteger("183972267825065276461950095037660073391");
  text(b.toString(), 50, 100);

}
Tagged:

Answers

  • edited November 2015

    Only a tiny fraction of Java's API is available for PJS:
    http://ProcessingJS.org/reference/

    You'll have to find an equivalent JS library for it, I'm afraid...

  • oh I see.

    So in this post, someone lists a few of them. http://stackoverflow.com/questions/14531137/what-javascript-library-can-i-use-to-manipulate-big-integers

    Is it a matter of downloading one of them and importing it in my sketch? How exactly do I do this?

    thank you

  • Answer ✓
    • AFAIK, just paste the ".js" along w/ your ".pde" in "JavaScript Mode".
    • Then you can instantiate the new class from that file inside ".pde".
    • Notice you're gonna lose cross-mode compatibility w/ "Java Mode".
    • Unless that JS' API matches that of Java's...
  • I also tried to import de.bezier.guido.*; from the 'Import library' menu and it fails as well.

    (https://github.com/fjenett/Guido)

    Is it for the same reason? Can I not import any other libraries and limit my self to the functionalities of the core functions listed in the reference you pointed out?

  • Ah ok, let me try your suggestion above.

    thank you for helping

  • ok great! I managed to make bigInteger to work. I see the syntax is somewhat different, as well as non jave compatible as you mentioned.

    I will now look for a gui library as well.

    thank you so much!

Sign In or Register to comment.