Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
9b9f7a00
Commit
9b9f7a00
authored
Nov 21, 2023
by
Zebediah Figura
Committed by
Alexandre Julliard
Nov 22, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msvcrt: Perform a base-10 logarithm using integer math.
Wine-Bug:
https://bugs.winehq.org/show_bug.cgi?id=55918
parent
8a25798e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
3 deletions
+17
-3
bnum.h
dlls/msvcrt/bnum.h
+1
-1
printf.h
dlls/msvcrt/printf.h
+16
-2
No files found.
dlls/msvcrt/bnum.h
View file @
9b9f7a00
...
...
@@ -22,7 +22,7 @@
#define EXP_BITS 11
#define MANT_BITS 53
static
const
int
p10s
[]
=
{
1
,
10
,
100
,
1000
,
10000
,
100000
,
1000000
,
10000000
,
100000000
};
static
const
int
p10s
[]
=
{
1
,
10
,
100
,
1000
,
10000
,
100000
,
1000000
,
10000000
,
100000000
,
1000000000
};
#define LIMB_DIGITS 9
/* each DWORD stores up to 9 digits */
#define LIMB_MAX 1000000000
/* 10^9 */
...
...
dlls/msvcrt/printf.h
View file @
9b9f7a00
...
...
@@ -135,6 +135,20 @@ static inline int mbstowcs_len(wchar_t *wcstr, const char *mbstr,
}
return
wlen
;
}
static
inline
unsigned
int
log2i
(
unsigned
int
x
)
{
ULONG
result
;
_BitScanReverse
(
&
result
,
x
);
return
result
;
}
static
inline
unsigned
int
log10i
(
unsigned
int
x
)
{
unsigned
int
t
=
((
log2i
(
x
)
+
1
)
*
1233
)
/
4096
;
return
t
-
(
x
<
p10s
[
t
]);
}
#endif
static
inline
int
FUNC_NAME
(
pf_output_wstr
)(
FUNC_NAME
(
puts_clbk
)
pf_puts
,
void
*
puts_ctx
,
...
...
@@ -635,7 +649,7 @@ static inline int FUNC_NAME(pf_output_fp)(FUNC_NAME(puts_clbk) pf_puts, void *pu
if
(
!
b
->
data
[
bnum_idx
(
b
,
b
->
e
-
1
)])
first_limb_len
=
1
;
else
first_limb_len
=
floor
(
log10
(
b
->
data
[
bnum_idx
(
b
,
b
->
e
-
1
)])
)
+
1
;
first_limb_len
=
log10i
(
b
->
data
[
bnum_idx
(
b
,
b
->
e
-
1
)]
)
+
1
;
radix_pos
=
first_limb_len
+
LIMB_DIGITS
+
e10
;
round_pos
=
flags
->
Precision
;
...
...
@@ -700,7 +714,7 @@ static inline int FUNC_NAME(pf_output_fp)(FUNC_NAME(puts_clbk) pf_puts, void *pu
if
(
!
b
->
data
[
bnum_idx
(
b
,
b
->
e
-
1
)])
i
=
1
;
else
i
=
floor
(
log10
(
b
->
data
[
bnum_idx
(
b
,
b
->
e
-
1
)])
)
+
1
;
i
=
log10i
(
b
->
data
[
bnum_idx
(
b
,
b
->
e
-
1
)]
)
+
1
;
if
(
i
!=
first_limb_len
)
{
first_limb_len
=
i
;
radix_pos
++
;
...
...
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