mirror of
https://github.com/louisrubet/rpn
synced 2024-12-28 09:58:52 +01:00
#83: removed bin command and representation
This commit is contained in:
parent
9842efcf20
commit
977bee3a7a
6 changed files with 7 additions and 19 deletions
|
@ -31,8 +31,6 @@ void object::show(FILE* stream)
|
||||||
case number::hex:
|
case number::hex:
|
||||||
mpfr_fprintf(stream, string(MPFR_FORMAT_HEX).c_str(), ((number*)this)->_value.mpfr);
|
mpfr_fprintf(stream, string(MPFR_FORMAT_HEX).c_str(), ((number*)this)->_value.mpfr);
|
||||||
break;
|
break;
|
||||||
case number::bin:
|
|
||||||
fprintf(stream, "<binary representation TODO>\n");
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case cmd_string:
|
case cmd_string:
|
||||||
|
|
|
@ -151,8 +151,7 @@ struct number : public object
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
dec,
|
dec,
|
||||||
hex,
|
hex
|
||||||
bin
|
|
||||||
} _representation;
|
} _representation;
|
||||||
|
|
||||||
// precision
|
// precision
|
||||||
|
|
|
@ -396,8 +396,6 @@ static bool get_number(const string& entry, program& prog, string& remaining_ent
|
||||||
string beg = entry.substr(0, 2);
|
string beg = entry.substr(0, 2);
|
||||||
if (beg == "0x" || beg == "0X")
|
if (beg == "0x" || beg == "0X")
|
||||||
num->_representation = number::hex;
|
num->_representation = number::hex;
|
||||||
else if (beg == "0b" || beg == "0B")
|
|
||||||
num->_representation = number::bin;
|
|
||||||
else
|
else
|
||||||
num->_representation = number::dec;
|
num->_representation = number::dec;
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,6 @@ program::keyword_t program::s_keywords[] =
|
||||||
{ cmd_undef, "", NULL, "\nREAL REPRESENTATION"},
|
{ cmd_undef, "", NULL, "\nREAL REPRESENTATION"},
|
||||||
{ cmd_keyword, "dec", &program::dec, "decimal representation" },
|
{ cmd_keyword, "dec", &program::dec, "decimal representation" },
|
||||||
{ cmd_keyword, "hex", &program::hex, "hexadecimal representation" },
|
{ cmd_keyword, "hex", &program::hex, "hexadecimal representation" },
|
||||||
{ cmd_keyword, "bin", &program::bin, "binary representation" },
|
|
||||||
{ cmd_keyword, "std", &program::std, "standard floating numbers representation. ex: [25] std" },
|
{ cmd_keyword, "std", &program::std, "standard floating numbers representation. ex: [25] std" },
|
||||||
{ cmd_keyword, "fix", &program::fix, "fixed point representation. ex: 6 fix" },
|
{ cmd_keyword, "fix", &program::fix, "fixed point representation. ex: 6 fix" },
|
||||||
{ cmd_keyword, "sci", &program::sci, "scientific floating point representation. ex: 20 sci" },
|
{ cmd_keyword, "sci", &program::sci, "scientific floating point representation. ex: 20 sci" },
|
||||||
|
|
|
@ -144,13 +144,6 @@ void hex()
|
||||||
((number*)_stack->back())->_representation = number::hex;
|
((number*)_stack->back())->_representation = number::hex;
|
||||||
}
|
}
|
||||||
|
|
||||||
void bin()
|
|
||||||
{
|
|
||||||
MIN_ARGUMENTS(1);
|
|
||||||
ARG_MUST_BE_OF_TYPE(0, cmd_number);
|
|
||||||
((number*)_stack->back())->_representation = number::bin;
|
|
||||||
}
|
|
||||||
|
|
||||||
void dec()
|
void dec()
|
||||||
{
|
{
|
||||||
MIN_ARGUMENTS(1);
|
MIN_ARGUMENTS(1);
|
||||||
|
|
|
@ -18,12 +18,13 @@ erase
|
||||||
|
|
||||||
# real hex
|
# real hex
|
||||||
erase
|
erase
|
||||||
0x1234
|
0x1234 0x10.10
|
||||||
-> stack should be 4660
|
-> stack should be 0x1.234p+12, 0x1.01p+4
|
||||||
|
|
||||||
drop
|
# real hex (2)
|
||||||
0x10.10
|
dec swap dec swap
|
||||||
-> stack should be 16.0625
|
-> stack should be 4660, 16.0625
|
||||||
|
erase
|
||||||
|
|
||||||
# real binary
|
# real binary
|
||||||
erase
|
erase
|
||||||
|
|
Loading…
Reference in a new issue