Creating a Scientific notation method
So I'm currently trying to write my own method/class to return scientific notation display of my number. I have a tried a several different things but I keep getting this error back: "not all code paths return a value".
I have gone through different versions of how to write it out but I think I'm just missing something really dumb if someone could help me out that would be awesome. Thank you.
Snippet of program:
public Text SciNote(double a)
{
if (a > 1000)
{
var expo = (System.Math.Floor(System.Math.Log10(System.Math.Abs(a))));
var Ncoin = (a / System.Math.Pow(10, expo));
coinsText.text = Ncoin.ToString("F2") + "e" + expo.ToString("F0");
}
coinsText.text = a.ToString("F2");
}
Ocasially I'll have an error where it says "can not implicitly convert to type Text.
I figured it out, needed "public Text SciNote" to be " Void SciNote"
Your answer
![](https://koobas.hobune.stream/wayback/20220613013018im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Get length of array C# 3 Answers
Method Group 1 Answer
OnUnityAdsDidFinish() repeats when I restart the game 1 Answer
Arbitrary line in one method prevents another for working? 1 Answer