Hi,
Attached are a couple of fixes to r_hash_entropy, that were preventing
it from reaching the maximum (8) for an even distribution of bytes.
The s/logf/log/ change fixes a rounding error, which somehow caused
8.000000 to be rounded down to 0x07 in the zoom view.
Glyn
diff -r 504bcd044654 libr/hash/entropy.c
--- a/libr/hash/entropy.c Fri Feb 25 13:13:35 2011 +0100
+++ b/libr/hash/entropy.c Fri Feb 25 13:18:27 2011 +0000
@@ -19,10 +19,10 @@
R_API double r_hash_entropy(const ut8 *data, ut64 size) {
double h = 0, px, log2;
- unsigned char x;
+ unsigned int x;
- log2 = logf ((double)2);
- for (x = 0; x < 255; x++) {
+ log2 = log ((double)2);
+ for (x = 0; x <= 255; x++) {
px = get_px (x, data, size);
if (px > 0)
h += -px * (log (px)/log2);
_______________________________________________
radare mailing list
[email protected]
http://lists.nopcode.org/listinfo.cgi/radare-nopcode.org