Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
2d788ac2
Commit
2d788ac2
authored
Oct 26, 2014
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
variables: try to retain exact value converting float to fraction
parent
3705c13a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
13 deletions
+20
-13
src/misc/variables.c
src/misc/variables.c
+20
-13
No files found.
src/misc/variables.c
View file @
2d788ac2
...
@@ -32,6 +32,7 @@
...
@@ -32,6 +32,7 @@
# include <search.h>
# include <search.h>
#endif
#endif
#include <assert.h>
#include <assert.h>
#include <float.h>
#include <math.h>
#include <math.h>
#include <limits.h>
#include <limits.h>
#ifdef __GLIBC__
#ifdef __GLIBC__
...
@@ -1307,19 +1308,25 @@ int (var_InheritURational)(vlc_object_t *object,
...
@@ -1307,19 +1308,25 @@ int (var_InheritURational)(vlc_object_t *object,
unsigned
d
=
strtol
(
*
next
?
&
next
[
1
]
:
"0"
,
NULL
,
0
);
unsigned
d
=
strtol
(
*
next
?
&
next
[
1
]
:
"0"
,
NULL
,
0
);
if
(
*
next
==
'.'
)
{
if
(
*
next
==
'.'
)
{
/* Interpret as a float number */
/* Interpret as a (finite positive) float number */
double
r
=
us_atof
(
tmp
);
const
int
ubits
=
CHAR_BIT
*
sizeof
(
unsigned
);
double
c
=
ceil
(
r
);
int
exp
;
if
(
c
>=
UINT_MAX
)
double
f
=
frexp
(
us_atof
(
tmp
),
&
exp
);
goto
error
;
unsigned
m
=
c
;
if
(
!
isgreaterequal
(
f
,
0
.))
if
(
m
>
0
)
{
goto
error
;
/* negative or not a number */
d
=
UINT_MAX
/
m
;
n
=
r
*
d
;
if
(
exp
<=
1
-
ubits
)
{
}
else
{
n
=
0
;
/* too small */
n
=
0
;
d
=
1
;
d
=
0
;
}
else
if
(
exp
<=
0
)
{
}
n
=
floor
(
scalbn
(
f
,
ubits
-
1
+
exp
));
d
=
1u
<<
(
ubits
-
1
);
}
else
if
(
exp
<=
ubits
)
{
n
=
floor
(
scalbn
(
f
,
ubits
));
d
=
1u
<<
(
ubits
-
exp
);
}
else
goto
error
;
/* too big */
}
else
if
(
*
next
==
'\0'
)
{
}
else
if
(
*
next
==
'\0'
)
{
/* plain integer given */
/* plain integer given */
*
num
=
n
;
*
num
=
n
;
...
...
Write
Preview
Markdown
is supported
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