| 6 | 1/1 | 返回列表 |
| 查看: 1417 | 回復(fù): 5 | ||
lbh_xt新蟲 (小有名氣)
|
[求助]
linux下的計(jì)算精度的設(shè)置
|
|
大家好,最近在linux下用lammps算的東西,結(jié)果數(shù)據(jù)都保只保留了四位小數(shù)點(diǎn),而在window下卻是16位的,請問這是什么原因?是linux系統(tǒng)和windows系統(tǒng)的原因?還是lammps在兩個系統(tǒng)下不同的原因? 例如: linux下: 2278.2239 windows下:2278.3329129329420233 我想要更高的截?cái)鄶?shù)據(jù)(16位),請問應(yīng)該怎么設(shè)置 |


鐵桿木蟲 (正式寫手)
|
// dump_custom.cpp in constructor(): ... for (int i = 0; i < size_one; i++) { if (vtype == INT) format_default = strcat(format_default,"%d " ;else if (vtype == DOUBLE) format_default = strcat(format_default,"%g " ;else if (vtype == STRING) strcat(format_default,"%s " ;vformat = NULL; } ... 可以將%g 改成 %20.14g或者其它什么的,不知你為什么要這么高的精度,好像缺省的就夠用了。 |
新蟲 (小有名氣)

新蟲 (小有名氣)
|
不是dump,我是在lammps里用variable equal進(jìn)行運(yùn)算,可是數(shù)據(jù)的精度不夠,所以都都導(dǎo)致為0 了,腳本中本分如下: variable poten1 equal pe variable p1 equal ${poten1} ... variable poten2 equal pe variable p2 equal ${poten1} ... variable poten3 equal pe variable p3 equal ${poten1} ... variable poten4 equal pe variable p4 equal ${poten1} ... variable mype equal ${p1}+${p2}-${p3}-${p4} ... 然后在log文件中,就會有這樣的表示: variable poten1 equal pe variable p1 equal ${poten1} variable p1 equal 2775.42283 ... variable poten2 equal pe variable p2 equal 2775.42283 ... variable poten3 equal pe variable p3 equal 2775.42283 ... variable poten4 equal pe variable p4 equal 2775.42283 ... variable mype equal ${p1}+${p2}-${p3}-${p4} variable mype equal 2775.42283+2775.42283-2775.42283-2775.42283 所以就等于0了。 但實(shí)際上,每個variable先都進(jìn)行了相應(yīng)的操作,所以上面的p1,p2,p3,p4都是不相等的數(shù),例如:2775.422832424和2775.4228292324,只是它四舍五入了。這種情況在windows下就不會產(chǎn)生,windows下會輸出到小數(shù)點(diǎn)后面很多位,而這個linux下就只能截?cái)嗟胶?位了,請問該怎么處理。 |

鐵桿木蟲 (正式寫手)
| 6 | 1/1 | 返回列表 |
| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 309求調(diào)劑 +17 | 誰不是少年 2026-03-29 | 17/850 |
|
|---|---|---|---|---|
|
[考研] 材料工程085601數(shù)二英一335求調(diào)劑 +5 | 雙馬尾痞老板2 2026-03-31 | 5/250 |
|
|
[考研] 085600,321分求調(diào)劑 +7 | 大饞小子 2026-03-31 | 7/350 |
|
|
[考研] 化學(xué)0703 調(diào)劑 306分 一志愿211 +10 | 26要上岸 2026-03-28 | 10/500 |
|
|
[考研] 南京大學(xué)化學(xué)調(diào)劑 +11 | 景隨風(fēng) 2026-03-29 | 16/800 |
|
|
[考研] 085600材料與化工調(diào)劑 +16 | kikiki7 2026-03-30 | 16/800 |
|
|
[考研] 一志愿鄭大材料工程290求調(diào)劑 +12 | Youth_ 2026-03-30 | 12/600 |
|
|
[有機(jī)交流]
10+3
|
kaobao456 2026-03-29 | 4/200 |
|
|
[考研] 抱歉 +4 | 田洪有 2026-03-30 | 4/200 |
|
|
[考研]
|
鐘llll 2026-03-26 | 5/250 |
|
|
[考研] 292求調(diào)劑 +13 | 是妍子也是研子 2026-03-30 | 13/650 |
|
|
[考研] 0703 化學(xué) 求調(diào)劑,一志愿山東大學(xué) 342 分 +7 | Shern—- 2026-03-28 | 7/350 |
|
|
[考研] 【求調(diào)劑】085601材料工程專碩 | 總分272 | +7 | 腳滑的守法公民 2026-03-27 | 7/350 |
|
|
[考研] 298求調(diào)劑 +4 | 種圣賜 2026-03-28 | 4/200 |
|
|
[考研] 070300求調(diào)劑306分 +4 | 26要上岸 2026-03-27 | 4/200 |
|
|
[考研] 339求調(diào)劑,想調(diào)回江蘇 +6 | 烤麥芽 2026-03-27 | 8/400 |
|
|
[考研] 求調(diào)劑 +4 | 零八# 2026-03-27 | 4/200 |
|
|
[考研] 0856調(diào)劑 +5 | 求求讓我有書讀?/a> 2026-03-26 | 6/300 |
|
|
[考研] 324求調(diào)劑 +5 | hanamiko 2026-03-26 | 5/250 |
|
|
[考研] 07化學(xué)303求調(diào)劑 +5 | 睿08 2026-03-25 | 5/250 |
|