Subversion Repositories HomeAutomation

Rev

Rev 1314 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 1314 Rev 1322
Line 81... Line 81...
81
{
81
{
82
    unsigned int num = 0;
82
    unsigned int num = 0;
83
 
83
 
84
    for (int n = bin.length() - 1; n >= 0; n--)
84
    for (int n = bin.length() - 1; n >= 0; n--)
85
    {
85
    {
86
        if (bin[n] == '1') num += (unsigned int)pow(2.0f, (int)(bin.length()
86
        if (bin[n] == '1') num += (unsigned int)pow(2.0f, (int)(bin.length() - 1 - n));
87
                - 1 - n));
-
 
88
    }
87
    }
89
 
88
 
90
    return num;
89
    return num;
91
}
90
}
92
 
91
 
Line 283... Line 282...
283
    for (unsigned int n = 0; n < bin.length(); n++)
282
    for (unsigned int n = 0; n < bin.length(); n++)
284
        inverted += (bin[n] == '1' ? '0' : '1');
283
        inverted += (bin[n] == '1' ? '0' : '1');
285
 
284
 
286
    return inverted;
285
    return inverted;
287
}
286
}
-
 
287
 
-
 
288
float LOG2of2 = log2f(2);
-
 
289
 
-
 
290
unsigned int stateCount2bitCount(unsigned int stateCount)
-
 
291
{
-
 
292
    // Special case for zero states
-
 
293
    if (stateCount == 0)
-
 
294
    {
-
 
295
        return 1;
-
 
296
    }
-
 
297
 
-
 
298
    return ceil(log2f(stateCount + 1) / LOG2of2);
-
 
299
}
-
 
300
 
288
 
301
 
289
}
302
}
290
}
303
}