Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
abc
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
abc
Commits
782125c6
Commit
782125c6
authored
Jan 28, 2017
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Custom floating-point number.
parent
ec6b7653
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
0 deletions
+15
-0
src/sat/xsat/xsatFloat.h
+15
-0
No files found.
src/sat/xsat/xsatFloat.h
View file @
782125c6
...
...
@@ -70,6 +70,7 @@ static inline xFloat_t xSat_FloatCreateConst2point5() { retur
static
inline
xFloat_t
xSat_FloatCreateMaximum
()
{
return
xSat_Uint2Float
(
0xFFFFFFFF
);
}
static
inline
float
xSat_Float2Float
(
xFloat_t
a
)
{
assert
(
a
.
Exp
<
127
);
return
Abc_Int2Float
(((
a
.
Exp
+
127
)
<<
23
)
|
((
a
.
Mnt
&
0x7FFF
)
<<
8
));
}
static
inline
xFloat_t
xSat_FloatFromFloat
(
float
a
)
{
int
A
=
Abc_Float2Int
(
a
);
assert
(
a
>=
1
.
0
);
return
xSat_FloatCreate
((
A
>>
23
)
-
127
,
0x8000
|
((
A
>>
8
)
&
0x7FFF
));
}
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
...
...
@@ -180,6 +181,13 @@ static inline void xSat_FloatTest()
xFloat_t
c1p5
=
xSat_FloatCreateConst1point5
();
xFloat_t
c2p5
=
xSat_FloatCreateConst2point5
();
xFloat_t
c1_
=
xSat_FloatFromFloat
(
1
.
0
);
xFloat_t
c2_
=
xSat_FloatFromFloat
(
2
.
0
);
xFloat_t
c3_
=
xSat_FloatFromFloat
(
3
.
0
);
xFloat_t
c12_
=
xSat_FloatFromFloat
(
12
.
0
);
xFloat_t
c1p5_
=
xSat_FloatFromFloat
(
1
.
5
);
xFloat_t
c2p5_
=
xSat_FloatFromFloat
(
2
.
5
);
xFloat_t
sum1
=
xSat_FloatAdd
(
c1
,
c1p5
);
xFloat_t
mul1
=
xSat_FloatMul
(
c2
,
c1p5
);
...
...
@@ -197,6 +205,13 @@ static inline void xSat_FloatTest()
printf
(
"1.5 = %f
\n
"
,
xSat_Float2Float
(
c1p5
)
);
printf
(
"2.5 = %f
\n
"
,
xSat_Float2Float
(
c2p5
)
);
printf
(
"Converted 1 = %f
\n
"
,
xSat_Float2Float
(
c1_
)
);
printf
(
"Converted 2 = %f
\n
"
,
xSat_Float2Float
(
c2_
)
);
printf
(
"Converted 3 = %f
\n
"
,
xSat_Float2Float
(
c3_
)
);
printf
(
"Converted 12 = %f
\n
"
,
xSat_Float2Float
(
c12_
)
);
printf
(
"Converted 1.5 = %f
\n
"
,
xSat_Float2Float
(
c1p5_
)
);
printf
(
"Converted 2.5 = %f
\n
"
,
xSat_Float2Float
(
c2p5_
)
);
printf
(
"1.0 + 1.5 = %f
\n
"
,
xSat_Float2Float
(
sum1
)
);
printf
(
"2.0 * 1.5 = %f
\n
"
,
xSat_Float2Float
(
mul1
)
);
...
...
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