Fortran Coder

查看: 29536|回复: 19
打印 上一主题 下一主题

[数值问题] Fortran计算结果浮点数异常

[复制链接]

490

帖子

4

主题

0

精华

大宗师

F 币
3298 元
贡献
1948 点

水王勋章元老勋章热心勋章

楼主
发表于 2018-1-22 22:16:42 | 显示全部楼层
本帖最后由 pasuka 于 2018-1-22 22:18 编辑

请将公式的系数,譬如1.00011表示成单精度1.00011E0,双精度1.00011D0,180改成单精度1.8E2,双精度1.8D2
年角代码中的(n-1)改写成real(n-1)

490

帖子

4

主题

0

精华

大宗师

F 币
3298 元
贡献
1948 点

水王勋章元老勋章热心勋章

沙发
发表于 2018-1-23 11:21:38 | 显示全部楼层
向着光亮 发表于 2018-1-23 10:12
号的,我复制给你
[mw_shl_code=fortran,true]program ex0109
real*8:: delta(366),y(366),ws(366),sl(366 ...

依旧是问题代码:
1、明明打开同一个文件,open语句为何放在do循环内?
2、有open无close;
3、为啥不能举一反三把3*y(n)这类表述也改成3.0E0*y(n)?
师傅领进门,修行在自身

490

帖子

4

主题

0

精华

大宗师

F 币
3298 元
贡献
1948 点

水王勋章元老勋章热心勋章

板凳
发表于 2018-1-23 13:21:25 | 显示全部楼层
向着光亮 发表于 2018-1-23 12:40
我刚才又算了一遍,还是不行,大体思路我明白了,主要是角度和弧度的互换,太容易出错了,你刚才说的纬度 ...

坚持角度制的话,请查找手册,譬如:
https://gcc.gnu.org/onlinedocs/g ... an/ASIND.html#ASIND
9.20 ASIND — Arcsine function, degrees
Description:
ASIND(X) computes the arcsine of its X in degrees (inverse of SIND(X)).

This function is for compatibility only and should be avoided in favor of standard constructs wherever possible.

Standard:
GNU Extension, enabled with -fdec-math.

Class:
Elemental function

Syntax:
RESULT = ASIND(X)

Arguments:
X        The type shall be either REAL and a magnitude that is less than or equal to one - or be COMPLEX.
Return value:
The return value is of the same type and kind as X. The real part of the result is in degrees and lies in the range -90 \leq \Re \asin(x) \leq 90.

Example:
program test_asind
  real(8) :: x = 0.866_8
  x = asind(x)
end program test_asind
Specific names:
Name        Argument        Return type        Standard
ASIND(X)        REAL(4) X        REAL(4)        GNU Extension
DASIND(X)        REAL(8) X        REAL(8)        GNU Extension
See also:
Inverse function: SIND Radians function: ASIN

490

帖子

4

主题

0

精华

大宗师

F 币
3298 元
贡献
1948 点

水王勋章元老勋章热心勋章

地板
发表于 2018-1-23 21:49:45 | 显示全部楼层
向着光亮 发表于 2018-1-23 21:18
tan计算的不就是一个数值吗?为何是弧度制?

请先回顾计算方法课程的相关内容:三角函数值
传送门:
http://blog.csdn.net/eric88/article/details/17031311
您需要登录后才可以回帖 登录 | 极速注册

本版积分规则

捐赠本站|Archiver|关于我们 About Us|小黑屋|Fcode ( 京ICP备18005632-2号 )

GMT+8, 2024-5-4 11:51

Powered by Tencent X3.4

© 2013-2024 Tencent

快速回复 返回顶部 返回列表