sputt / wabbitemu

Wabbitemu is a Z80 TI Calculator emulator

Home Page:http://wabbitemu.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ctrl+C copies absurd values for imprecise decimals

typecasto opened this issue · comments

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.

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

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.

commented

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.