|
Sorry for missreading your post
log2 is used in music among others for as octave utility
and for floating point arithmetics:
"By knowing that the exponent and mantissa are both two's compliment values and also knowing that a floating point number is a very close approximation of the same number expressed in log2 form, a quick inversions and square roots can be implimented with simple functions. For example a quick inverse is calculated by negating the exponent and mantissa bits."
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
|
toxctt wrote:
what should we need a Base-2 log for ??
Since computers use base-2 numbers, binary logarithms come in very handy. For example, what is the next highest power of two for the number 79?
int x = 1 + (int) log2(79);
If a binary tree has N nodes, what is the minimum number of levels in the tree? log2(13) + 1 yields the answer of 4.
http://www.encyclopedia4u.com/b/binary-logarithm.html
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
oh, that's nice ! lol
but since it's very useful, how to find such expression ? did you find such by yourself, or with docs ?
TOXCCT >>> GEII power
|
|
|
|
|
toxcct wrote:
oh, that's nice ! lol
Are you laughing facetiously?
toxcct wrote:
how to find such expression ?
What expression?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
DavidCrow wrote:
Are you laughing facetiously?
no, i promise you i find all these very nice...
DavidCrow wrote:
What expression?
such expression : int x = 1 + (int) log2(79);
TOXCCT >>> GEII power
|
|
|
|
|
toxcct wrote:
such expression : int x = 1 + (int) log2(79);
I just made that statement up. A log2() function does not exist in the standard library, so if you needed one, it would have to be created.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
DavidCrow wrote:
log2() function does not exist in the standard library
yes, that was implicit and understood.
what i want to know is about the entiere expression (int x = 1 + (int) log2(79); ) ; did you find it after been documented, or by a thinking of your own ?
TOXCCT >>> GEII power
|
|
|
|
|
toxcct wrote:
did you find it after been documented, or by a thinking of your own ?
The latter. Since log2(79) is 6.3, I needed to take the integer part of that and add one, yielding 7. Thus 27 is 128, the next highest power of 2 for the number 79.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
This expression is a solution to the problem DavidCrow presented: "-- What is the next highest power of two for the number 79?"
The expression first evaluates the power to which 2 must be raised to reach 79, then adds 1 to this. It all bases on the way logarithms are defined: "Base N logarithm from number Y will result in the power to which N must be raised to result in Y".
Most obviously, he just made up a quick problem, and solved it, to give an example. So, he thought it on his own, made it up.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Aaaarrrrgggghhh!! you really want to compute binary logarithm of integers with float logarithm function? I think that integer approach would be much much more quicker:
int log2(int x)
{
int lg;
for(lg = -1; x != 0; x /= 2, lg++);
return lg;
}
Robert-Antonio
"Science is a differerntial equation.
Religion is a boundary condition."
|
|
|
|
|
Robert A. T. Káldy wrote:
...with float logarithm function
The log2() function I demonstrated was theoretical. Were it to be implemented, int s would surely be used over double s.
Robert A. T. Káldy wrote:
I think...
But without actual metrics, we don't really know.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Hi,
Is there a way to Kill a process programatically, something like :
KillProcess (name) ?
I want to kill a process which I can see in the process list of CTRL+ALT+DEL and I want to make sure it's not there before doing something.
Thanks,
Shay
|
|
|
|
|
One lame way to do so:
http://www.sysinternals.com/ntw2k/freeware/pstools.shtml
you can issue a call to pskill or do your own using
or open the process and issue a call to TerminateProcess
or using
http://www.codeproject.com/threads/pausep.asp
and replacing the SuspendThread by TerminateThread
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Hi,
Is there a way to Kill a process programatically, something like :
KillProcess (name) ?
I want to kill a process which I can see in the process list of CTRL+ALT+DEL and I want to make sure it's not there before doing something.
Thanks,
Shay
|
|
|
|
|
Hi anybody has any idea about this : how to print a html file (in html format , not text format) without showing any printer dialog and being able to customize the orientation (portrait/landscape) . Any links are welcome
Thanks
xxx
|
|
|
|
|
Hi guys
When my App is running in W98 I receive sometimes a "Resource necessary non available".
There is a way to avoid this message in W98? Programatically? With an utility?
Best Regards
Doc
|
|
|
|
|
At the point in which the message is displayed, what resource is your application asking for (e.g., bitmap, icon, menu, dialog, string table)?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
In the dialog where the problem appears I'm using CLayeredBitmapCtrl (I get from CStatic controls) with a lot of layers.
Best Regards
Doc
|
|
|
|
|
I'm not familar with that class but perhaps you could ask its author why it would fail given the way you are using it.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Hi!.
I'm writing an application and I have to build configuration, for _DEBUG and for _DEBUG +_UNICODE.
In the programa I use many TRACE() and AfxMessageBox that show some text, the problem is that I must duplicate every line of code with these function because it must be one's with the macro _T() or L for _UNICODE and others without it.
For example:
<br />
#ifdef _UNICODE<br />
TRACE(L"Hello build with UNICODE support");<br />
#else<br />
TRACE("Hello build without UNICODE support");<br />
#endif<br />
<br />
There is other way to write this kind of stuff, without check the build configuration?.<br />
<br />
Thanks! <br />
<br />
Demian.
|
|
|
|
|
Why not a Macro that expand into this?
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Check out the _T() macro:
TRACE(_T("Hello build with UNICODE support"));
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Hi.
I'm using the marco _T() indeed.
The macro _T() wrapped L.
Demian.
|
|
|
|
|
Demian Panello wrote:
The macro _T() wrapped L.
Of course. And in the case where _UNICODE is not defined, _T() resolves to nothing. This will eliminate the need for all of the #ifdef directives.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|