bugfix: floating point precision; added strutils.formatFloat
This commit is contained in:
parent
8c799da867
commit
064417fc5a
13 changed files with 156 additions and 56 deletions
18
tests/accept/run/tfloat3.nim
Normal file
18
tests/accept/run/tfloat3.nim
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
|
||||
import math, strutils
|
||||
|
||||
{.emit: """
|
||||
void printFloats(void) {
|
||||
double y = 1.234567890123456789;
|
||||
|
||||
printf("C double: %.10f, %.10f ", exp(y), cos(y));
|
||||
}
|
||||
""".}
|
||||
|
||||
proc c_printf(frmt: CString) {.importc: "printf", header: "<stdio.h>", varargs.}
|
||||
proc printFloats {.importc, nodecl.}
|
||||
|
||||
var x: float = 1.234567890123456789
|
||||
c_printf("Nimrod %.10f, %.10f ", exp(x), cos(x))
|
||||
printFloats()
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue