how to write??

J

janek

Hello all!
My question:
How to write (in Builder C++)
10^(-b*z)
cause i have no idea :(
Thanks for any help..
johnnyB
 
W

White Wolf

janek said:
Hello all!
My question:
How to write (in Builder C++)
10^(-b*z)
cause i have no idea :(

If I am not mistaking it is pow(10.0, b*z); You need to include math.h
 
B

Buster

janek said:
Hello all!
My question:
How to write (in Builder C++)
10^(-b*z)
cause i have no idea :(
Thanks for any help..
johnnyB

I'm guessing, but try 'std::pow (10, - b * z)'.
You have to #include <cmath> first.
 
W

White Wolf

Buster said:
I'm guessing, but try 'std::pow (10, - b * z)'.
You have to #include <cmath> first.

Before we go into a debate again on the cmath/std:: vs. math/nostd I have
proposed the latter for two reasons. One: unfortunately I have seen
compilers where include a cxxx header is sure recipe for disater. The other
(way less important) is that it also works in C.
 
A

Aggro

White said:
Before we go into a debate again on the cmath/std:: vs. math/nostd I have
proposed the latter for two reasons. One: unfortunately I have seen
compilers where include a cxxx header is sure recipe for disater. The other
(way less important) is that it also works in C.

Um.. this is C++ group, right? I think it is better to use C++ style,
rather than C style if we are writing C++ code. Even if the C code would
work. If the compiler can't handle the standard C++ there are two solutions:
- Get a better compiler (or new version).
- Use the bad/evil C-style as you suggested. But only if you are really
tied to that crappy compiler. ;)

I don't know any good reasons why someone should do this. I just think
that if you go to England, you should try to speak English there,
instead of Spain or some other language. I'm pretty sure they will
understand you better if you do so.
 
W

White Wolf

Aggro said:
Um.. this is C++ group, right? I think it is better to use C++ style,
rather than C style if we are writing C++ code.

Is it? Even if it means your code not compiling anymore?
Even if the C code
would work. If the compiler can't handle the standard C++ there are
two solutions:
- Get a better compiler (or new version).

Obviously you do not work in a big company.
- Use the bad/evil C-style as you suggested. But only if you are
really tied to that crappy compiler. ;)

It is not bad or evil. It is standard.
I don't know any good reasons why someone should do this.

Because it is standard? Because it makes it possible to use the C style
code from both C and C++? Because it makes his code compile and work?
I just think
that if you go to England, you should try to speak English there,
instead of Spain or some other language. I'm pretty sure they will
understand you better if you do so.

Yes. But it is absolutely irrelevant here.
 
B

Buster

White Wolf said:
Before we go into a debate again on the cmath/std:: vs. math/nostd I have
proposed the latter for two reasons. One: unfortunately I have seen
compilers where include a cxxx header is sure recipe for disater. The other
(way less important) is that it also works in C.

No argument here. My reasons for using cmath: (a) I thought it was less likely
to cause a flame war. (b) It looks cooler.

Peace out,
Buster.
 
J

Jeremy Cowles

White Wolf said:
Is it? Even if it means your code not compiling anymore?


You didn't know if the code would compile or not with *his* compiler. The
solution is to post it in the standard/ISO C++ code and then make a note:

"if this doesnt work with your compiler..."

Afterall, this is supposed to be a 'group for Standard C++, isn't it?


~
Jeremy
 
W

White Wolf

Jeremy said:
You didn't know if the code would compile or not with *his* compiler.
The solution is to post it in the standard/ISO C++ code and then make
a note:

"if this doesnt work with your compiler..."

Afterall, this is supposed to be a 'group for Standard C++, isn't it?

math.h and pow() without std *is standard C++*. Period.
 
G

Gavin Deane

White Wolf said:
math.h and pow() without std *is standard C++*. Period.

Yes, but the xxx.h headers are deprecated in favour of cxxx aren't
they? I can see where you're coming from. I don't use cxxx myself
headers because my compiler doesn't put the names in the std namespace
at all. But I think it is appropriate to prefer the non-deprecated
answer here.

GJD
 
A

Attila Feher

Gavin said:
Yes, but the xxx.h headers are deprecated in favour of cxxx aren't
they?

They are. But deprecated does not mean they are not part of the standard.
And if you ask (as I did) the intentions of people on the comitee you would
also know there as of today (when designing the C++ for the next 10 years)
there are absolutely no intentions to remove those headers-
I can see where you're coming from. I don't use cxxx myself
headers because my compiler doesn't put the names in the std namespace
at all.

Then I guess you see what I mean. :) This topic is not black and white.
But I think it is appropriate to prefer the non-deprecated
answer here.

I was like this for a while as well until some very well known names have
convinced me otherwise. Anyway it is worth to mention that there are those
cxxx headers and that (in theory) they should be used.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,141
Messages
2,570,818
Members
47,367
Latest member
mahdiharooniir

Latest Threads

Top