| 6 | 1/1 | 返回列表 |
| 查看: 1415 | 回復(fù): 5 | ||
lbh_xt新蟲 (小有名氣)
|
[求助]
linux下的計算精度的設(shè)置
|
|
大家好,最近在linux下用lammps算的東西,結(jié)果數(shù)據(jù)都保只保留了四位小數(shù)點,而在window下卻是16位的,請問這是什么原因?是linux系統(tǒng)和windows系統(tǒng)的原因?還是lammps在兩個系統(tǒng)下不同的原因? 例如: linux下: 2278.2239 windows下:2278.3329129329420233 我想要更高的截斷數(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進行運算,可是數(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了。 但實際上,每個variable先都進行了相應(yīng)的操作,所以上面的p1,p2,p3,p4都是不相等的數(shù),例如:2775.422832424和2775.4228292324,只是它四舍五入了。這種情況在windows下就不會產(chǎn)生,windows下會輸出到小數(shù)點后面很多位,而這個linux下就只能截斷到后5位了,請問該怎么處理。 |

鐵桿木蟲 (正式寫手)
| 6 | 1/1 | 返回列表 |
| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 070300化學(xué)求調(diào)劑 +5 | 小黃鴨寶 2026-03-30 | 5/250 |
|
|---|---|---|---|---|
|
[考研] 一志愿北京化工大學(xué)材料與化工(085600)296求調(diào)劑 +25 | 稻妻小編 2026-03-26 | 25/1250 |
|
|
[考研] 一志愿哈爾濱工業(yè)大學(xué)材料與化工方向336分 +12 | 辰沐5211314 2026-03-26 | 12/600 |
|
|
[碩博家園] 求調(diào)劑 有機化學(xué)考研356分 +10 | Nadiums 2026-03-25 | 11/550 |
|
|
[考研] 南京大學(xué)化學(xué)調(diào)劑 +10 | 景隨風(fēng) 2026-03-29 | 15/750 |
|
|
[考研] 375求調(diào)劑 +6 | 雨夏整夜 2026-03-29 | 6/300 |
|
|
[考研] 一志愿南航 335分 | 0856 | GPA 4.07 | 有科研經(jīng)歷 +8 | cccchenso 2026-03-29 | 8/400 |
|
|
[考研] 311求調(diào)劑 +6 | 冬十三 2026-03-24 | 6/300 |
|
|
[考研] 343求調(diào)劑085601 +3 | 要努力學(xué)習(xí)x 2026-03-29 | 3/150 |
|
|
[考研] 299求調(diào)劑 +10 | 15188958825 2026-03-25 | 10/500 |
|
|
[考研] 329求調(diào)劑 +10 | 鈕恩雪 2026-03-25 | 10/500 |
|
|
[考研] 085600,專業(yè)課化工原理,321分求調(diào)劑 +5 | 大饞小子 2026-03-28 | 5/250 |
|
|
[考研] 一志愿太原理工安全工程300分,求調(diào)劑 +5 | 0857求調(diào)劑. 2026-03-24 | 6/300 |
|
|
[考研] 304求調(diào)劑 +6 | 曼殊2266 2026-03-27 | 6/300 |
|
|
[考研] 352分 化工與材料 +5 | 海納百川Ly 2026-03-27 | 5/250 |
|
|
[考研] 265求調(diào)劑 +8 | 小木蟲085600 2026-03-27 | 8/400 |
|
|
[考研] 化學(xué)調(diào)劑 +4 | 愛吃番茄的旭 2026-03-24 | 5/250 |
|
|
[考研] 266分求材料化工冶金礦業(yè)等專業(yè)的調(diào)劑 +4 | 哇呼哼呼哼 2026-03-26 | 4/200 |
|
|
[考研] 考研一志愿蘇州大學(xué)初始315(英一)求調(diào)劑 +3 | sbdksD 2026-03-24 | 4/200 |
|
|
[考研] 340求調(diào)劑 +5 | 話梅糖111 2026-03-24 | 5/250 |
|