Skip to main content

Questions tagged [dc]

dc is an arbitrary (bignum) precision desc calculator.

Filter by
Sorted by
Tagged with
11 votes
1 answer
968 views

Why does the "dc" command exit(1) when using q(uit)?

$ echo "$?" 0 $ echo 'q' | dc || echo "$?" 1 Why is using q to quit dc considered an error? (The test was run on Ubuntu 20.4.)
Ray Butterworth's user avatar
4 votes
1 answer
334 views

dc and standard input or heredoc with string command?

dc can read command from a file or/and from standard input. If I want to print user input : cat essai_dc [enter a number : ] n ? p dc essai_dc enter a number : 4 4 Now, if I try with a heredoc :...
ctac_'s user avatar
  • 1,960
13 votes
3 answers
2k views

Losing precision with dc

I want to use dc to handle some base 16 numbers with hexadecimal points but I'm running into precision problems. For example, below I'm multiplying F423F.FD by 100, both hex. The expected answer is ...
Yimin Rong's user avatar
2 votes
2 answers
311 views

How come dc print splits up long number

When running the dc utility, if I input a very large number, say: 999999999999999999999999999999999999999999999999999999999999999999999999 When I print it out using p, I get: ...
MarksCode's user avatar
  • 135
1 vote
1 answer
247 views

How to capture user input in dc?

I'd like to handle user input in dc. For ?, info dc indicates: '?' ...
Yimin Rong's user avatar
0 votes
1 answer
57 views

executing 2 scripts with connection

I've been given some challenge: there is an application that provides me some postfix expression and expects to get a solution within 5 seconds. If there is no solution, it quits, otherwise, it ...
user1977050's user avatar
0 votes
1 answer
129 views

How can I supress GNU dc warnings?

When some invalid or undefined commands are executed in dc, it usually just prints a warning. Example: cp dc: stack empty This is nice most of the time, however, there are cases where this is ...
SE - stop firing the good guys's user avatar
2 votes
1 answer
379 views

How to get the difference between numbers using dc?

Input: > printf 1\n\2\n3\n 1 2 3 Desired output: 0 1 1 Typing printf 1\n\2\n3\n | dc -e '-p' the output is: dc: stack empty dc: stack empty
ncomputers's user avatar
  • 1,524
6 votes
3 answers
1k views

dc unix : preserving initial value even after storing new value at the same array index

I'm unable to understand this example given in manpage of dc: $ dc 1 0:a 0Sa 2 0:a La 0;ap 1 To me answer should be 2 because: 1 0:a Here we store 1 at 0th position of array a. 0Sa Now ...
rootkea's user avatar
  • 186