mirror of
https://github.com/louisrubet/rpn
synced 2025-01-19 10:26:22 +01:00
#136: Corrected some problems: dec and hex commands wrongly removed, bug in command sub, 05-real.txtand 04-stack.txt typo
This commit is contained in:
parent
855f99ed2e
commit
8944940da5
4 changed files with 18 additions and 11 deletions
|
@ -42,6 +42,8 @@ program::keyword_t program::s_keywords[] =
|
|||
{ cmd_keyword, "sq", &program::square, "(or sqr) square" },
|
||||
{ cmd_keyword, "sqr", &program::square, "" },
|
||||
{ cmd_keyword, "abs", &program::rpn_abs, "absolute value" },
|
||||
{ cmd_keyword, "dec", &program::dec, "decimal representation" },
|
||||
{ cmd_keyword, "hex", &program::hex, "hexadecimal representation" },
|
||||
{ cmd_keyword, "prec", &program::precision, "get float precision in bits when first stack is not a number\n\t"
|
||||
"set float precision in bits when first stack entry is a number. ex: 256 prec" },
|
||||
{ cmd_keyword, "round", &program::round, "set float rounding mode.\n\tex: [\"nearest\", \"toward zero\", \"toward +inf\", \"toward -inf\", \"away from zero\"] round" },
|
||||
|
|
|
@ -109,7 +109,7 @@ void strsub()
|
|||
|
||||
long first = long(((number*)_stack->get_obj(1))->_value) - 1;
|
||||
long last = long(((number*)_stack->get_obj(0))->_value) - 1;
|
||||
long len = ((ostring*)_stack->get_obj(0))->_len;
|
||||
long len = ((ostring*)_stack->get_obj(2))->_len;
|
||||
bool result_is_void = false;
|
||||
|
||||
_stack->pop_back();
|
||||
|
@ -119,12 +119,17 @@ void strsub()
|
|||
first = 0;
|
||||
if (last < 0)
|
||||
last = 0;
|
||||
if (first > len && last > len)
|
||||
result_is_void=true;
|
||||
else
|
||||
{
|
||||
if (first > len)
|
||||
first = len -1;
|
||||
if (last > len)
|
||||
last = len -1;
|
||||
if (first > last)
|
||||
result_is_void=true;
|
||||
}
|
||||
|
||||
if (!result_is_void)
|
||||
{
|
||||
|
|
|
@ -35,7 +35,7 @@ erase
|
|||
erase
|
||||
|
||||
# drop2
|
||||
3
|
||||
1 2 3
|
||||
drop2
|
||||
-> stack size should be 1
|
||||
-> stack should be 1
|
||||
|
@ -95,7 +95,7 @@ erase
|
|||
depth
|
||||
-> stack size should be 4
|
||||
-> stack should be 1, 2, 3, 3
|
||||
>erase
|
||||
erase
|
||||
|
||||
# test pick
|
||||
1 2 3 4 2 pick
|
||||
|
|
|
@ -25,7 +25,7 @@ erase
|
|||
erase
|
||||
|
||||
# real hex (2)
|
||||
0x1.234p+12, 0x1.01p+4
|
||||
0x1.234p+12 0x1.01p+4
|
||||
dec swap dec swap
|
||||
-> stack should be 4660, 16.0625
|
||||
erase
|
||||
|
@ -284,7 +284,7 @@ erase
|
|||
|
||||
# sqrt (2)
|
||||
sqrt
|
||||
-> error should be 2
|
||||
-> error should be 3
|
||||
|
||||
# sq (1)
|
||||
12 sq
|
||||
|
|
Loading…
Reference in a new issue