I am wondering if there is a faster way to convert integer to float if it is known to be Q1.24 format numbers, as compared to the builtin_conv_RtoF which handles 32 bits input ?
I am wondering if there is a faster way to convert integer to float if it is known to be Q1.24 format numbers, as compared to the builtin_conv_RtoF which handles 32 bits input ?
Divya.P - Moved from SHARC Processors to CrossCore Embedded Studio and Add-ins. Post date updated from Wednesday, November 19, 2025 10:39 PM UTC to Thursday, November 20, 2025 4:32 AM UTC to reflect the move.
JohnG2024 - Moved from CrossCore Embedded Studio and Add-ins to SHARC Processors. Post date updated from Thursday, November 20, 2025 4:32 AM UTC to Friday, November 21, 2025 1:37 PM UTC to reflect the move.
Hi,
Thank you for your inquiry.
As you are aware "conv_RtoF" is hardwired for Q1.31 input, so Q1.23 values must be shifted or scaled to match its expected fractional bit alignment.
Instead of shifting and calling conv_RtoF, you can directly scale in C:
Below is sample code to cast the fract-typed argument to float type without using the built-in conversion.
#include <stdint.h>
#include <stdio.h>
float q1_23_to_float(int32_t qval) {
return (float)qval / (1 << 24); // direct scaling
}
int main() {
int32_t qval = 0x00800000; // 0.5 in Q1.23
float f = q1_23_to_float(qval);
printf("Q1.23: 0x%08X -> float: %f\n", qval, f);
return 0;
}
Hope this helps.
Best Regards,
Santhakumari.V
Thanks for the response. My understanding is that the cast to a float will invoke the built-in function and then a divide so not be more efficient than f=(float)(qval<<8). Also in the question I made a typo that should have said Q1.23 for the 24 bit inputs. In the long ago past I think adi did provide a Conv_Q1.23ToFloat() function. If there is assembly code for that anywhere would be appreciated.
Hi,
Unfortunately, we are unable to locate any information in our database regarding the function “Conv_Q1.23ToFloat()”. Could you please share how you obtained this reference, whether from Ezone or private support?
If available, please provide the Ezone link or the support ticket ID.
Waiting for your reply.
Best Regards,
Santhakumari.V
Sorry I don't have any more information, which is why I posted here. I am using the built-in function which works correctly. Was just looking at optimizing for mips by using a function that knows it only will operate on 24 bit data.