振荡器 [英] oscillator

查看:77
本文介绍了振荡器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经编写了这个用于证券分析的ob / os振荡器。唯一的

是结果总是负面的。如-96。我查看了

以及此代码,对我来说看起来很好。有没有麻烦?


#include< stdio.h>

#include< stdlib.h>


双os(双倍价格,双倍价格)

{double os;

os = price-ma / ma * 100;

返回操作系统;

}

int main(int argc,char * argv [])

{if(argc!= 3)

{fprintf(stderr," usage error \ n");

退出(EXIT_FAILURE);

}

双倍价格,马;

price = strtod(argv [1],NULL);

ma = strtod(argv [2],NULL);

printf("%f.2 \ n",os(price,ma));

返回0;

}


谢谢。

I have written this ob/os oscillator for securities analysis. The only
thing is that the result is always negative. Such as -96. I have looked over
and over this code and it looks fine to me. Is there any trouble?

#include <stdio.h>
#include <stdlib.h>

double os(double price,double ma)
{ double os;
os=price-ma/ma*100;
return os;
}
int main(int argc,char *argv[])
{ if (argc!=3)
{fprintf(stderr,"usage error\n");
exit(EXIT_FAILURE);
}
double price,ma;
price=strtod(argv[1],NULL);
ma=strtod(argv[2],NULL);
printf("%f.2\n",os(price,ma));
return 0;
}

Thanks.

推荐答案

文章< lCg2k.548
In article <lCg2k.548


8q2。 269 @ trnddc02>,

Bill Cunningham< no **** @ nspam.comwrote:
8q2.269@trnddc02>,
Bill Cunningham <no****@nspam.comwrote:

我写了这个ob / os证券分析振荡器。唯一的问题是结果总是消极的。如-96。我已经查看了
以及这段代码,它对我来说很好看。有什么麻烦吗?
I have written this ob/os oscillator for securities analysis. The only
thing is that the result is always negative. Such as -96. I have looked over
and over this code and it looks fine to me. Is there any trouble?


> double os(双倍价格,双倍价格)
{double os;

os = price -ma / ma * 100;

返回操作系统;
}
>double os(double price,double ma)
{ double os;
os=price-ma/ma*100;
return os;
}



当ma是双倍时,ma / ma总是将是1(除非ma为0

或无穷大或NaN),所以你的操作程序总是会返回

价格 - 100。


*可能*你的意思是,os =(price - ma)/ ma * 100; ??


-

任何足够先进的bug都与功能无法区分。

- Rich Kulawiec

When ma is a double, ma/ma is always going to be 1 (unless ma is 0
or infinity or NaN), so your os routine is always going to return
price - 100 .

*Possibly* you meant something like, os = (price - ma) / ma * 100; ??

--
"Any sufficiently advanced bug is indistinguishable from a feature."
-- Rich Kulawiec




" Walter Roberson" < ro ****** @ ibd.nrc-cnrc.gc.cawrote in message

news:g2 ********** @ canopus.cc.umanitoba.ca ...

"Walter Roberson" <ro******@ibd.nrc-cnrc.gc.cawrote in message
news:g2**********@canopus.cc.umanitoba.ca...

当ma是双倍时,ma / ma总是为1(除非ma为0

或无穷大或NaN),所以你的os例程总是会返回

价格 - 100.


*可能*你的意思是,os =(价格 - 马)/ ma * 100; ??
When ma is a double, ma/ma is always going to be 1 (unless ma is 0
or infinity or NaN), so your os routine is always going to return
price - 100 .

*Possibly* you meant something like, os = (price - ma) / ma * 100; ??



啊,我明白了。非常感谢沃尔特。那一定是问题所在。尚未使用

到所有C'的括号:)


Bill

Ah I see. Thanks much Walter. That must be the problem. Not quite used
to all C''s parenthesis yet :)

Bill


这篇关于振荡器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆