Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
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
Libraries
mruby
Commits
b87bfe73
Commit
b87bfe73
authored
May 04, 2014
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2182 from cremno/use-isfinite
simply use `isfinite`
parents
4be6f1c7
86cfcd20
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
4 deletions
+5
-4
include/mruby/value.h
include/mruby/value.h
+1
-0
mrbgems/mruby-sprintf/src/sprintf.c
mrbgems/mruby-sprintf/src/sprintf.c
+1
-1
src/numeric.c
src/numeric.c
+3
-3
No files found.
include/mruby/value.h
View file @
b87bfe73
...
@@ -60,6 +60,7 @@ typedef short mrb_sym;
...
@@ -60,6 +60,7 @@ typedef short mrb_sym;
# define snprintf _snprintf
# define snprintf _snprintf
# if _MSC_VER < 1800
# if _MSC_VER < 1800
# include <float.h>
# include <float.h>
# define isfinite(n) _finite(n)
# define isnan _isnan
# define isnan _isnan
# define isinf(n) (!_finite(n) && !_isnan(n))
# define isinf(n) (!_finite(n) && !_isnan(n))
# define signbit(n) (_copysign(1.0, (n)) < 0.0)
# define signbit(n) (_copysign(1.0, (n)) < 0.0)
...
...
mrbgems/mruby-sprintf/src/sprintf.c
View file @
b87bfe73
...
@@ -999,7 +999,7 @@ retry:
...
@@ -999,7 +999,7 @@ retry:
char
fbuf
[
32
];
char
fbuf
[
32
];
fval
=
mrb_float
(
mrb_Float
(
mrb
,
val
));
fval
=
mrb_float
(
mrb_Float
(
mrb
,
val
));
if
(
isnan
(
fval
)
||
isinf
(
fval
))
{
if
(
!
isfinite
(
fval
))
{
const
char
*
expr
;
const
char
*
expr
;
const
int
elen
=
3
;
const
int
elen
=
3
;
...
...
src/numeric.c
View file @
b87bfe73
...
@@ -309,7 +309,7 @@ flodivmod(mrb_state *mrb, mrb_float x, mrb_float y, mrb_float *divp, mrb_float *
...
@@ -309,7 +309,7 @@ flodivmod(mrb_state *mrb, mrb_float x, mrb_float y, mrb_float *divp, mrb_float *
}
}
else
{
else
{
mod
=
fmod
(
x
,
y
);
mod
=
fmod
(
x
,
y
);
if
(
isinf
(
x
)
&&
!
isinf
(
y
)
&&
!
isnan
(
y
))
if
(
isinf
(
x
)
&&
isfinite
(
y
))
div
=
x
;
div
=
x
;
else
else
div
=
(
x
-
mod
)
/
y
;
div
=
(
x
-
mod
)
/
y
;
...
@@ -495,7 +495,7 @@ flo_finite_p(mrb_state *mrb, mrb_value num)
...
@@ -495,7 +495,7 @@ flo_finite_p(mrb_state *mrb, mrb_value num)
{
{
mrb_float
value
=
mrb_float
(
num
);
mrb_float
value
=
mrb_float
(
num
);
return
mrb_bool_value
(
!
(
isinf
(
value
)
||
isnan
(
value
)
));
return
mrb_bool_value
(
isfinite
(
value
));
}
}
/* 15.2.9.3.10 */
/* 15.2.9.3.10 */
...
@@ -626,7 +626,7 @@ flo_round(mrb_state *mrb, mrb_value num)
...
@@ -626,7 +626,7 @@ flo_round(mrb_state *mrb, mrb_value num)
}
}
if
(
ndigits
>
0
)
{
if
(
ndigits
>
0
)
{
if
(
isinf
(
number
)
||
isnan
(
number
))
return
num
;
if
(
!
isfinite
(
number
))
return
num
;
return
mrb_float_value
(
mrb
,
number
);
return
mrb_float_value
(
mrb
,
number
);
}
}
return
mrb_fixnum_value
((
mrb_int
)
number
);
return
mrb_fixnum_value
((
mrb_int
)
number
);
...
...
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