Optimal Int to Float Function
#1
Lightbulb 
This code is the most optimal way to convert an integer of any value to float, supporting negative values and being self contained:

Code:
# Args:    r3 = Integer to convert to float
# Returns: f1 = Float representation of the input integer

lis r4, 0x5980
ori r4, r4, 0x0004
stw r4, -0x4 (sp)
lis r4, 0x4330

lfs f1, -0x4 (sp)

xoris r3, r3, 0x8000
stw r3, -0x4 (sp)
stw r4, -0x8 (sp)

lfd f0, -0x8 (sp)
fsubs f1, f0, f1
blr

NOTE: This is meant to be called as a function
Super Mario Eclipse, what Super Mario Sunshine could've been.
Reply


Messages In This Thread
Optimal Int to Float Function - by JoshuaMK - 11-10-2020, 10:35 AM
RE: Optimal Int to Float Function - by Vega - 11-10-2020, 10:20 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)