0

When using multiple pipe commands on same input of big numbers with many digits, how does this impact the precision of numbers. Do they get truncated. Note that I said multiple times as input is used and then re-used. Assuming that the functions used for input do not impact the precision of numbers, does "pipe |" impact it ?

Also, my assumption of functions performing action on input of large numbers with many digits, is incorrect. If functions include awk then my assumption is incorrect, what about 'sed'.

4
  • 2
    As far as a pipe is concerned, a number is just a series of characters. Piping (as opposed to the functions you may be using) transmits characters unchanged. It does not affect precision in any way. Do you have some reason to think otherwise?
    – John1024
    Jun 7, 2019 at 6:18
  • 1
    It's not so much the pipes or the number of stages used in a pipeline that matters. The pipe itself just forwards data (unchanged) to the next stage of the pipeline. It has more to do with what each stage of the pipeline does, how they handle the numbers, if they introduce rounding errors etc. Are you have a current issue in relation to this? If so, you may want to tell us what that issue is.
    – Kusalananda
    Jun 7, 2019 at 6:56
  • @Kusalananda if that was an answer, it would be the one I would ↟. Jun 7, 2019 at 7:28
  • @ctrl-alt-delor It wasn't really an answer. I was trying to get to the bottom of what the issue might be that the user experiences. If the user gets back to us about that, I (or anyone else) may obviously turn it into part of an answer.
    – Kusalananda
    Jun 7, 2019 at 7:32

2 Answers 2

0

Here we have five pipes and, as you can see, the characters out are exactly the same as the characters in:

$ echo '1.23456789012345678901234567890' | cat | cat | cat | cat | cat
1.23456789012345678901234567890

Pipes transmit characters unchanged. Nothing in the pipe cares whether a series characters represents a number or not. To a pipe, everything is just a series of characters.

1
  • To a pipe, everything is just a series of bytes (it is just passed on). Jun 7, 2019 at 7:29
0

A pipe

cmd1 | cmd2

gets the standard output of command cmd1 and feeds it unchanged to the standard input of command cmd2. While it applies buffering (and therefore is something to keep in mind if you're dealing with large I/O and need realtime results), it doesn't do any mathematical operation on it, and will not affect number precision in any way.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .