Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Zwinkau
libfirm
Commits
13c1bd27
Commit
13c1bd27
authored
May 15, 2003
by
Michael Beck
Browse files
Fixed floating point minimum values, must be -*_MAX, not *_MIN !
Added floating point conversions... [r1216]
parent
dc467413
Changes
2
Hide whitespace changes
Inline
Side-by-side
ir/tv/fltcalc.c
View file @
13c1bd27
...
...
@@ -83,17 +83,21 @@ LLDBL fc_val_to_float(const void *val)
void
fc_get_min
(
unsigned
int
num_bits
)
{
CLEAR_BUFFER
();
switch
(
num_bits
)
{
/*
* Beware: FLT_MIN is the "Minimum normalised float",
* not the smallest number in arithmetic sense
*/
switch
(
num_bits
)
{
case
32
:
value
=
FLT_M
IN
;
value
=
-
FLT_M
AX
;
break
;
case
64
:
value
=
DBL_M
IN
;
value
=
-
DBL_M
AX
;
break
;
case
80
:
default:
value
=
LDBL_M
IN
;
value
=
-
LDBL_M
AX
;
break
;
}
}
...
...
@@ -152,8 +156,17 @@ void fc_calc(const void *a, const void *b, int opcode)
int
fc_comp
(
const
void
*
a
,
const
void
*
b
)
{
if
(
CAST_IN
(
a
)
==
CAST_IN
(
b
))
return
0
;
else
return
(
CAST_IN
(
a
)
>
CAST_IN
(
b
))
?
(
1
)
:
(
-
1
);
char
buf1
[
40
],
buf2
[
40
];
if
(
CAST_IN
(
a
)
==
CAST_IN
(
b
))
{
return
0
;
}
else
if
(
CAST_IN
(
a
)
>
CAST_IN
(
b
))
{
return
1
;
}
else
{
return
-
1
;
}
}
char
*
fc_print_dec
(
const
void
*
a
,
char
*
buf
,
int
buflen
)
...
...
ir/tv/tv.c
View file @
13c1bd27
...
...
@@ -169,6 +169,9 @@ static int overflows(tarval *tv)
break
;
case
irms_float_number
:
/*
* TODO: check NaNs
*/
if
(
fc_comp
(
tv
->
value
,
get_mode_max
(
tv
->
mode
)
->
value
)
==
1
)
return
1
;
if
(
fc_comp
(
tv
->
value
,
get_mode_min
(
tv
->
mode
)
->
value
)
==
-
1
)
return
1
;
break
;
...
...
@@ -630,20 +633,32 @@ tarval *tarval_convert_to(tarval *src, ir_mode *m)
break
;
case
irms_float_number
:
switch
(
get_mode_sort
(
m
))
{
case
irms_float_number
:
tv
.
mode
=
m
;
tv
.
length
=
src
->
length
;
tv
.
value
=
src
->
value
;
if
(
overflows
(
&
tv
))
{
return
tarval_bad
;
}
return
INSERT_TARVAL
(
&
tv
);
default:
break
;
}
break
;
case
irms_int_number
:
switch
(
get_mode_sort
(
m
))
{
switch
(
get_mode_sort
(
m
))
{
case
irms_int_number
:
case
irms_character
:
tv
.
mode
=
m
;
tv
.
mode
=
m
;
tv
.
length
=
src
->
length
;
tv
.
value
=
src
->
value
;
tv
.
value
=
src
->
value
;
if
(
overflows
(
&
tv
))
{
return
tarval_bad
;
}
return
INSERT_TARVAL
(
&
tv
);
case
irms_internal_boolean
:
...
...
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