|
If you like, you can use a method other than fopen to open the file, read a line of text, and use sscanf to parse it.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
wasn't sscanf designed to read from strings ? (C-syle strings i heard)...
TOXCCT >>> GEII power
|
|
|
|
|
Sure, but it works just fine. The only problem with sscanf is that it is MUCH easier to shoot yourself in the foot or introduce buffer overruns.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
I'm confused. If you use CreateFile to open the file and ReadFile to read from it, you can use sscanf to parse the string you read.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
I am developing software for a startup. However, I am not complete sure that I am developing it in the right language. We are currently using C#. The algorithm we are using to solve construction problems can have over 2,000,000 attributes. DO you think it would be better to code it in C++...My gut tells me yes..because I will be able to run linux clustered servers as opposed to windows servers.......
What do you think....Hong Kong Expat....http://sterlingwright.blogspot.com
|
|
|
|
|
Yes use C++ - C#'s advantage is that is highly geared towards the web. Number crunching is where C++ has a clear advantage, plus if you write it with non-MFC libraries it is portable
|
|
|
|
|
I think that if I'd known you'd posted this question all over the site, I would not have answered.
One area where C++ might give you an advantage is the STL, which C# does not have ( obviously ).
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Christian Graus wrote:
I think that if I'd known you'd posted this question all over the site, I would not have answered.
I know the point you were trying to make, but I found this post in only one other forum. What other places was it posted to?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Hello everyone,
I was wondering if there was a way to calculate the log2 of a number. I know there are functions for calculating the ln, log and log10, but don't see one for log2...maybe I'm missing it or there's a way to calc it using one of the other functions? Thanks!
"It seems that we're getting to the bottom of the barrel of squirrels." - my boss
|
|
|
|
|
Logarithms in different bases can be done using the formula
logy x = logz x / logz y
So you can use the log or log10 function to produce an approximate log2 function:
double log2(double val)
{
return log(val) / log(2.0);
}
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Argh, beat me to it! You must have posted that while I was in the process of replying.
Sometimes I feel like I'm a USB printer in a parallel universe.
|
|
|
|
|
Perfect! Thanks so much!
"It seems that we're getting to the bottom of the barrel of squirrels." - my boss
|
|
|
|
|
Use the Magic Log Forumla:
Logb x = Loga x/Loga b
A funcion that can get an arbitrary log:
double MyLog(double base, double x)
{
return log10(x) / log10(base);
}
...
double a = MyLog(2, 16);
Sometimes I feel like I'm a USB printer in a parallel universe.
|
|
|
|
|
just a curiosity and "personal culture" question...
what should we need a Base-2 log for ??
very thank you
TOXCCT >>> GEII power
|
|
|
|
|
A whole world of it:
Check on google log neperien
In breif:
Solving mathematical equations
Mathematical modeling of the movement of protons
Spatial Interpolation,
Mechanical modeling
Probability and statistics ....
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
wow woww stop it man, did you read my post ???
i didn't ask for log neperien (which is a Base-e log), but the need for having a log2 one !!!!
TOXCCT >>> GEII power
|
|
|
|
|
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)
|
|
|
|