Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
uPython-mirror
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
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
TASTE
uPython-mirror
Commits
3f58c1b9
Commit
3f58c1b9
authored
Feb 20, 2018
by
Damien George
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
leon: Add implementation of nearbyint.
parent
a115bde3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
0 deletions
+25
-0
leon-common/nearbyint.c
leon-common/nearbyint.c
+25
-0
No files found.
leon-common/nearbyint.c
0 → 100644
View file @
3f58c1b9
#include <stdint.h>
#include <math.h>
static
const
double
toint
=
4503599627370496
.
0
;
// 2**52
double
nearbyint
(
double
x
)
{
union
{
double
f
;
uint64_t
i
;
}
u
=
{
x
};
int
e
=
u
.
i
>>
52
&
0x7ff
;
int
s
=
u
.
i
>>
63
;
if
(
e
>=
0x3ff
+
52
)
{
// Large enough that it doesn't have a fraction
}
else
if
(
s
)
{
x
-=
toint
;
x
+=
toint
;
if
(
x
==
0
)
{
x
=
-
0
.
0
;
}
}
else
{
x
+=
toint
;
x
-=
toint
;
}
return
x
;
}
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