gpt4 book ai didi

Fortran bit separation between fraction and exponent(分数和指数之间的Fortran位分隔)

转载 作者:bug小助手 更新时间:2023-10-25 18:30:26 25 4
gpt4 key购买 nike



In Fortran, if I set rk=selected_real_kind(20)

how many bits are reserved for the fraction and how many for the exponent?

在Fortran中,如果我设置rk=SELECTED_REAL_KIND(20),为分数保留多少位,为指数保留多少位?


更多回答

This is not defined by Fortran, so please provide details on which compiler, computer, etc. you are interested in if you care about specifics.

这不是由Fortran定义的,因此如果您关心细节,请提供您感兴趣的编译器、计算机等的详细信息。

It's up to the compiler implementer. All you know is that for this kind precision( 1.0_rk ) returns at least 20.

这取决于编译器实现者。您所知道的是,对于这种类型,精度(1.0_rk)至少返回20。

And at a more practical level, selected_real_kind(n) simply returns an integer, it does nothing to reserve bits for anything. The value returned may be used as a kind parameter for a real entity, but could equally be an invalid number for that.

在更实际的级别上,SELECTED_REAL_KIND(N)只是返回一个整数,它不会为任何内容保留位。返回的值可以用作真实实体的Kind参数,但同样也可能是无效的数字。

@IanBush, one doesn't know even that (rk is not guaranteed to be a valid kind number for 1.0_rk, seeing as 20 is greater than 10).

@IanBush,甚至连这个都不知道(rk不能保证是1.0_rk的有效种类数,因为20大于10)。

If what you care about is more the properties of the model of real numbers for a given kind, you have various options like those shown in a related question. Depending on what properties you need to know, there may be more suitable inquiries to make. Please explain in more detail what you are wanting to know. (It's a very rare case where knowledge of the number of bits used to store the exponent is useful in a Fortran program.)

如果你更关心的是给定类型的实数模型的性质,你有各种各样的选择,就像相关问题中所示的那样。根据你需要了解的房产,可能会有更合适的查询。请更详细地解释你想知道的事情。(知道用于存储指数的位数在Fortran程序中非常有用,这种情况非常少见。)

优秀答案推荐
更多回答

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com