0

So my calculator is built for absolutely huge numbers. I am having a bit of fun here and making a base system based on the pokedex. So for example, base 151 would include all the Pokemon from generation 1, and base 809 goes all the way to Melmetal from Pokemon Go. The number 0 is represented by an unhatched pokemon egg.

I am running into a problem that I cannot figure out how to determine what is wrong, some of these symptoms may be from the same problem but I am unsure.

Symptom 1: Currently on my screen, I have it set to base pidgey (base 16) and I have input the base 10 number 80000006871717981. My math gives me the following remainders, with the corresponding representative images

(1)(1)(12)(3)(7)(9)(5)(1)(7)(9)(14)(1)(8)(6)(0)

Bulbasaur Bulbasaur Butterfree Venusaur Squirtle Blastoise Charmeleon Bulbasaur Squirtle Blastoise Kakuna Bulbasaur Wartortle Charizard Egg

And the output from simply converting with toString(16) is 11c3795179e1860. The output from the windows 10 calculator is ‭11C3795179E185D‬, implying that the e/Kakuna, 6/Charizard, and 0/Egg are wrong.

Symptom 2: Large numbers will have the same outputs. 1000000000000000001 and 1000000000000000000 both output as

(3)(458)(599)(562)(324)(484)(498)

Venasaur Mantyke Klang Yamask Torkoal Palkia Tepig

I feel like this is relating to the size of the number, but don't know how I can prevent this.

For symptom 2, I have tried casting the value to a BigInt when I set the value for input, but that just gave me nothing, only the output3 got anything calculated

function calculate()
    {
        document.getElementById('output').innerHTML= '';
        document.getElementById('output2').innerHTML= '';

        var base = {{base}};//gets base from the python code
        var input = document.getElementById('base10').value;

        document.getElementById('output3').innerHTML= parseInt(input).toString(16);

        var remainder = input % base;
        while(input > 0)
        {
            //alert(input + " % " + base + " = " + remainder);
            document.getElementById('output').innerHTML = '<img src="{{url_for('static', filename='images/')}}'+ remainder+'MS.png">' + document.getElementById('output').innerHTML;//adds the images of the pokemon
            document.getElementById('output2').innerHTML = '('+remainder+')' + document.getElementById('output2').innerHTML;
            input = parseInt(input / base);
            remainder = input % base;
        }
    }

For my expected results, as I mentioned the built in js function shows the base 16 test is accurate, but the windows 10 calculator says otherwise. I don't know which one to go with. And as far as the problems with large numbers go, I just need to make large base 10 numbers stay stable, not get scientific notation, and still be able to be processed.

Citrus Rain
  • 119
  • 1
  • 4
  • 16

0 Answers0