davidcsterratt / RTriangle

Port of the Triangle Two-Dimensional Quality Mesh Generator and Delaunay Triangulator to R
https://cran.r-project.org/package=RTriangle
9 stars 4 forks source link

Fix for small values of a (1e-7 and below) #1

Closed epipping closed 8 years ago

epipping commented 8 years ago

I've tested this as follows:

rm -f RTriangle_1.6-0.7.tar.gz
R CMD build .
R -e 'install.packages("./RTriangle_1.6-0.7.tar.gz")'
( cd tests && R -e 'source("testthat.R")' )

This sequences of commands yields a test failure for the new master~1 (because a new test was added that fails) and no test failure for the new master.

davidcsterratt commented 8 years ago

Thanks very much Elias - now merged and working for me.

There's no need to do more, but I realised two things just after I merged the code:

  1. The code is repeated. If you wanted to put the loop into a function - say format_decimal(char* fstr, int quant), that would be great
  2. Do we actually need to count the number of digits required; could we just overprovide? Would replacing the original sprintf(opts, "a%f", *REAL(a)) with sprintf(opts, "a%.106f", *REAL(a)) work? (We'd have to make sure that there was enough space in opts to prevent buffer overflows).
epipping commented 8 years ago
  1. Yes, that would work.
  2. That would make the code dramatically simpler of course; yes, we could totally do that.

I'll take a stab at it sometime later today!