I was wondering how to handle number prefix with large numbers, I was checking this game civwar, and I like how it handle the numbers, like even it was already in millions, eg. it show 50103.8k which I think it was 50.1 million.. any body know how to do that? I tried searching in formating but I cant find which it range to 4 digit with decimal
You do this by successively looking to find the biggest unit that your number fits, and tehn divide the original number by that order of magnitude. You'll recevie a string back, not a number. For example () Code (CSharp): string adaptMagnitude(float inNumber) { if (inNumber >= 1000000.0f) return (inNumber/100000.0f).ToString("F1") + "M"; if (inNumber >= 1000.0f) return (inNumber/1000.0f).ToString(F1)+ "K"; etc. }