sputt / wabbitemu

Wabbitemu is a Z80 TI Calculator emulator
http://wabbitemu.org
MIT License
294 stars 31 forks source link

Ctrl+C copies absurd values for imprecise decimals #27

Open typecasto opened 3 years ago

typecasto commented 3 years ago

It seems to copy it in scientific notation, but interprets the decimal point as an unsigned byte, rather than signed, or just not copying it in scientific notation.

Calculator used: TI-84 Plus C SE

Steps to reproduce: Enter 750/760 Hit Ctrl+C

Expected result: ".9868421053" is copied to the clipboard.

Actual result: "9.8684210526316*10^255" is copied to the clipboard.

shulist commented 3 years ago

I can also verify that this error is also ocurring in the TI-83+ v1.9.5.21

typecasto commented 3 years ago

I can also verify that this error is also ocurring in the TI-83+ v1.9.5.21

lol this repo seems kinda abandoned tbh, no commits since february, and if you don't count prs getting merged, no commits since 2018.

milnak commented 2 years ago

Took a quick look -- ans = (HLOCAL) GetRealAns(&lpCalc->cpu, buffer); calls symbol_to_string.

uint8_t type = mem_read(cpu->mem_c, ptr++);
int exp = (int) (mem_read(cpu->mem_c, ptr++) ^ 0x80);
...
if (abs(exp) > 14) {
    for (i = 0; i < sigdigs; i++) {
        *p++ = FP[i] + '0';
        if ((i + 1) < sigdigs && i == 0) *p++ = '.';
    }

    StringCbPrintf(p, 32, _T("*10^%d"), exp);
    p += _tcslen(p);
} else {

exp in this case is 255 so it triggers the abs(exp) > 14 case. I haven't dug into the code to see why exp == 255.