how to write?? | | |
Hello all!
My question:
How to write (in Builder C++)
10^(-b*z)
cause i have no idea :(
Thanks for any help..
johnnyB | | | | re: how to write??
janek wrote:[color=blue]
> Hello all!
> My question:
> How to write (in Builder C++)
> 10^(-b*z)
> cause i have no idea :([/color]
If I am not mistaking it is pow(10.0, b*z); You need to include math.h
--
WW aka Attila | | | | re: how to write??
"janek" <siojak@poczta.gazeta.pl> wrote in message
news:bka3pa$ljc$1@inews.gazeta.pl...[color=blue]
> Hello all!
> My question:
> How to write (in Builder C++)
> 10^(-b*z)
> cause i have no idea :(
> Thanks for any help..
> johnnyB[/color]
I'm guessing, but try 'std::pow (10, - b * z)'.
You have to #include <cmath> first. | | | | re: how to write??
Buster wrote:[color=blue]
> I'm guessing, but try 'std::pow (10, - b * z)'.
> You have to #include <cmath> first.[/color]
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.
--
WW aka Attila | | | | re: how to write??
White Wolf wrote:
[color=blue]
> 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.[/color]
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. | | | | re: how to write??
Aggro wrote:[color=blue]
> White Wolf wrote:
>[color=green]
>> 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.[/color]
>
> 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.[/color]
Is it? Even if it means your code not compiling anymore?
[color=blue]
> 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).[/color]
Obviously you do not work in a big company.
[color=blue]
> - Use the bad/evil C-style as you suggested. But only if you are
> really tied to that crappy compiler. ;)[/color]
It is not bad or evil. It is standard.
[color=blue]
> I don't know any good reasons why someone should do this.[/color]
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?
[color=blue]
> 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.[/color]
Yes. But it is absolutely irrelevant here.
--
WW aka Attila | | | | re: how to write??
"White Wolf" <wolof@freemail.hu> wrote[color=blue]
> 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.[/color]
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. | | | | re: how to write??
"White Wolf" <wolof@freemail.hu> wrote in message
news:bka5rn$3n4$1@phys-news1.kolumbus.fi...[color=blue]
> Aggro wrote:[color=green]
> > White Wolf wrote:
> >[color=darkred]
> >> 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.[/color]
> >
> > 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.[/color]
>
> Is it? Even if it means your code not compiling anymore?[/color]
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 | | | | re: how to write??
Jeremy Cowles wrote:[color=blue]
> "White Wolf" <wolof@freemail.hu> wrote in message
> news:bka5rn$3n4$1@phys-news1.kolumbus.fi...[color=green]
>> Aggro wrote:[color=darkred]
>>> White Wolf wrote:
>>>
>>>> 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.[/color]
>>
>> Is it? Even if it means your code not compiling anymore?[/color]
>
>
> 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?[/color]
math.h and pow() without std *is standard C++*. Period.
--
WW aka Attila | | | | re: how to write??
Thanks a lot .. it's worked :)
johnnyB | | | | re: how to write??
"White Wolf" <wolof@freemail.hu> wrote in message news:<bkah00$pno$1@phys-news1.kolumbus.fi>...[color=blue]
> Jeremy Cowles wrote:[color=green]
> > "White Wolf" <wolof@freemail.hu> wrote in message
> > news:bka5rn$3n4$1@phys-news1.kolumbus.fi...[color=darkred]
> >> Aggro wrote:
> >>> White Wolf wrote:
> >>>
> >>>> 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.
> >>
> >> Is it? Even if it means your code not compiling anymore?[/color]
> >
> >
> > 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?[/color]
>
> math.h and pow() without std *is standard C++*. Period.[/color]
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 | | | | re: how to write??
Gavin Deane wrote:[color=blue][color=green][color=darkred]
>>> Afterall, this is supposed to be a 'group for Standard C++, isn't
>>> it?[/color]
>>
>> math.h and pow() without std *is standard C++*. Period.[/color]
>
> Yes, but the xxx.h headers are deprecated in favour of cxxx aren't
> they?[/color]
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-
[color=blue]
> 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.[/color]
Then I guess you see what I mean. :-) This topic is not black and white.
[color=blue]
> But I think it is appropriate to prefer the non-deprecated
> answer here.[/color]
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.
--
Attila aka WW |  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,471 network members.
|