nortakales / vs-code-qalc

Interactive scratchpad calculator for VS Code
MIT License
70 stars 2 forks source link

Shift operation error? #17

Closed hongshui3000 closed 2 years ago

hongshui3000 commented 2 years ago

image

should show 0b0? ?

nortakales commented 2 years ago

It's a little clunky, but all of these variations seem to work and give a clue to what is going on:

bignumber(0b01) << 100       = 1,267,650,600,228,229,401,496,703,205,376
0b01 << bignumber(100)       = 1,267,650,600,228,229,401,496,703,205,376
bin(0b01 << bignumber(100))  = "0b10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
bin(bignumber(0b01) << 100)  = "0b10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"

Everything here (bin(), 0b01, <<, bignumber()) is handled by Math.js and not specific to this extension, so I don't have a great idea on how to solve this in a better way.

hongshui3000 commented 2 years ago

got it,thanks.