This is my first time using uint64 to handle file sizes >2GB. I am having a terrible time converting it to a readable value to show as text.
Code snippet I am using to convert 3534359552 to GB
uint64 size, value; // size=3534359552; value=(size/1073741824*100000)/100000; // = 3.291628...... rounded to 3 - or - value=(size*100)/1073741824; // = 329.16288.... rounded to 329
How to I format it to be like: 3.29 GB
This crashes:
IUtility->SNPrintf(BTUBuffer,15,"%llu%s%02llu GB",value,Locale->loc_DecimalPoint,value % 100);
There is a bit of a problem with 64-bit values and RawDoFmt() based functions like SNPrintf() in that while RawDoFmt() doesn't expect any alignment the C compiler aligns them to 64-bit so that's why I've added an extra %s and "" to work around this.
BTW since the fraction part is limited to 0-99 there is strictly no need to use a 64-bit value there so the SNPrintf() could be changed to:
Thank you. Works just like I needed.
Are there any other 64bit issues I need to look out for?
Not that I can think of.