Skip to content

Commit e2d1b65

Browse files
committed
Proper double-precision in ofstream #361
Reported-by: @cmdoug
1 parent 90cc9de commit e2d1b65

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/bamglib/MeshWrite.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ namespace bamg {
142142
if(bin) mode |=ios_base::binary;
143143
if(verbosity>9) cout << " mode = " << mode << " bin: " << ios_base::binary << " out: s" << ios_base::out << endl;
144144
ofstream f(filename,mode /*,ios::trunc*/);
145-
f.precision(12);
145+
f.precision(17);
146146

147147
if (f) switch (type) {
148148
case BDMesh: {
@@ -427,7 +427,7 @@ namespace bamg {
427427
assert(this && nbt);
428428
Int4 *reft = new Int4[nbt];
429429
Int4 nbInT = ConsRefTriangle(reft);
430-
f.precision(12);
430+
f.precision(17);
431431
f << nbv << " " << nbInT << endl;
432432
for (i = 0; i < nbt; i++)
433433
if (reft[i] >= 0) {
@@ -477,7 +477,7 @@ namespace bamg {
477477
assert(this && nbt);
478478
Int4 *reft = new Int4[nbt];
479479
Int4 nbInT = ConsRefTriangle(reft);
480-
f.precision(12);
480+
f.precision(17);
481481
Int4 nele = nbInT - NbOfQuad;
482482
Int4 ntri = nbInT - 2 * NbOfQuad;
483483
Int4 nqua = NbOfQuad;
@@ -512,7 +512,7 @@ namespace bamg {
512512
assert(this && nbt);
513513
Int4 *reft = new Int4[nbt];
514514
Int4 nbInT = ConsRefTriangle(reft);
515-
f.precision(12);
515+
f.precision(17);
516516
f << nbv << " " << nbInT << " " << nbe << endl;
517517

518518
for (i = 0; i < nbv; i++)
@@ -580,7 +580,7 @@ namespace bamg {
580580
Int4 *reft = new Int4[nbt];
581581
Int4 nbInT = ConsRefTriangle(reft);
582582
f << nbv << " " << nbInT << endl;
583-
cout.precision(12);
583+
cout.precision(17);
584584
for (i = 0; i < nbv; i++)
585585
f << i + 1 << " " << vertices[i].r.x << " " << vertices[i].r.y << " " << vertices[i].ref( )
586586
<< endl;
@@ -671,7 +671,7 @@ namespace bamg {
671671
}
672672
}
673673
{
674-
f.precision(12);
674+
f.precision(17);
675675
f << "\nVertices\n" << Th.nbv << endl;
676676
for (Int4 i = 0; i < Th.nbv; i++) {
677677
Vertex &v = Th.vertices[i];
@@ -836,7 +836,7 @@ namespace bamg {
836836
int nbreqv = 0;
837837
{
838838

839-
f.precision(12);
839+
f.precision(17);
840840
f << "\nVertices\n" << Gh.nbv << endl;
841841
for (Int4 i = 0; i < Gh.nbv; i++) {
842842
GeometricalVertex &v = Gh.vertices[i];

src/fflib/lgmesh.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ AnyType SaveMesh::operator()(Stack stack) const
653653
MeshPoint *mp(MeshPointStack(stack)) , mps=*mp;
654654
ofstream fp((*fn+".points").c_str());
655655
ofstream ff((*fn+".faces").c_str());
656-
fp.precision(12);
656+
fp.precision(17);
657657
if (verbosity>1)
658658
cout << " -- Opening files " << (*fn+".points") << " and " << (*fn+".faces") << endl;
659659
const Fem2D::Mesh & Th=*Thh;

0 commit comments

Comments
 (0)