Denna sida fungerar bättre med Javascript igång.
Startsida
Utforska
Hjälp
Registrera dig
Logga in
SisMaker
/
jiffy
Bevaka
1
Stjärnmärk
0
Förgrening
0
Kod
Ärenden
0
Pull-förfrågningar
0
Projects
0
Släpp
62
Wiki
Aktiviteter
Bläddra i källkod
issue
#31
: encode floating point numbers with less precision if possible. fails a few etap tests, though I believe it's due to the specific values expected
pull/32/head
Ryan Flynn
12 år sedan
förälder
3b6a1327d4
incheckning
b045a37391
1 ändrade filer
med
7 tillägg
och
1 borttagningar
Delad Vy
Diff Options
Show Stats
Download Patch File
Download Diff File
+7
-1
c_src/encoder.c
+ 7
- 1
c_src/encoder.c
Visa fil
@ -4,6 +4,7 @@
#
include
<assert.h>
#
include
<stdio.h>
#
include
<string.h>
#
include
<float.h>
#
include
"erl_nif.h"
#
include
"jiffy.h"
@ -401,7 +402,12 @@ enc_double(Encoder* e, double val)
start
=
&
(
e
-
>
p
[
e
-
>
i
]
)
;
sprintf
(
start
,
"
%0.20g
"
,
val
)
;
/
/
try
to
encode
doubles
using
the
fewest
digits
possible
.
.
.
if
(
snprintf
(
start
,
32
,
"
%.*g
"
,
DBL_DIG
,
val
)
>
FLT_DIG
)
{
/
/
.
.
.
fall
back
to
full
expansion
to
be
safe
snprintf
(
start
,
32
,
"
%.*g
"
,
LDBL_DIG
,
val
)
;
}
len
=
strlen
(
start
)
;
/
/
Check
if
we
have
a
decimal
point
Skriv
Förhandsgranska
Laddar…
Avbryt
Spara