mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-15 11:18:36 +12:00
Implement rounded_div
Round-to-nearest integral based division, optimized for unsigned integral. Used in sceNpTrophyGetGameProgress. Do not allow signed values for aligned_div(), align().
This commit is contained in:
parent
e30173a835
commit
db4041e079
6 changed files with 31 additions and 16 deletions
|
@ -929,8 +929,9 @@ error_code sceNpTrophyGetGameProgress(u32 context, u32 handle, vm::ptr<s32> perc
|
|||
const u32 trp_count = ctxt->tropusr->GetTrophiesCount();
|
||||
|
||||
verify(HERE), trp_count > 0 && trp_count <= 128;
|
||||
|
||||
*percentage = static_cast<s32>(std::lround((unlocked * 100.) / trp_count));
|
||||
|
||||
// Round result to nearest
|
||||
*percentage = rounded_div(unlocked * 100, trp_count);
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue