K
K
KPIshnik2014-01-31 15:54:31
C++ / C#
KPIshnik, 2014-01-31 15:54:31

How to find the Per-byte sum of a file?

Hi all. Does anyone know what the Per-byte sum of a file is and how it can be found. Google didn't give an answer. Thanks in advance.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladusch, 2014-01-31
@KPIshnik

We read data from the file byte by byte into a byte variable of size char or more, while adding them to a variable, for example sum += byte. Preferably into a variable like long long, unsigned long, etc. or in double. If the result is added to double or float, then to reduce accumulation and / or alignment errors, use the Kohan (Kogan) or pairwise summation algorithms (this is just an example).

F
FloppyFormator, 2014-01-31
@FloppyFormator

Maybe they meant it?

perl -le 'use bytes; local $/; $s+=ord $_ for map {split //, $_} <>; print $s' < /path/to/filename

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question