Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mpim-sw
libcdi
Commits
f2483736
Commit
f2483736
authored
Apr 07, 2016
by
Thomas Jahns
🤸
Browse files
Reduce branching in cdiEncodeTimeval.
parent
b0ce5d0e
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/taxis.c
View file @
f2483736
...
...
@@ -1317,21 +1317,15 @@ double cdiEncodeTimeval(int date, int time, taxis_t *taxis)
{
int
year
,
month
,
day
;
cdiDecodeDate
(
date
,
&
year
,
&
month
,
&
day
);
timevalue
=
date
/
100
;
if
(
day
!=
0
)
{
if
(
date
<
0
)
timevalue
-=
0
.
5
;
else
timevalue
+=
0
.
5
;
}
timevalue
=
date
/
100
+
copysign
((
double
)(
day
!=
0
)
*
0
.
5
,
(
double
)
date
);
}
else
{
int
hour
,
minute
,
second
;
cdiDecodeTime
(
time
,
&
hour
,
&
minute
,
&
second
);
if
(
date
<
0
)
timevalue
=
-
(
-
date
+
(
hour
*
3600
+
minute
*
60
+
second
)
/
86400
.);
else
timevalue
=
date
+
(
hour
*
3600
+
minute
*
60
+
second
)
/
86400
.;
timevalue
=
copysign
(
1
.
0
,
(
double
)
date
)
*
(
fabs
((
double
)
date
)
+
(
hour
*
3600
+
minute
*
60
+
second
)
/
86400
.);
}
}
else
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment