 Hello everyone, it is Crypto Groundz here and welcome back to another Unity Idle Game tutorial video, this episode 5.1 and today I'm going to be showing you guys how to make a standard notation for your idle game. If you end up enjoying this video, make sure you please leave a like as it really helps out the video. Subscribe to my channel for your new round here and turn on the bell so you can get notified for whenever I post new videos and when I go live. So let's hop right into it. So first before we actually start making this, I want to explain what standard notation is. So standard notation is where you have a number like this and you pronounce it as like 1 million. Okay, so this is 1 million, right? You also have 100,000. So this 100,000 basically becomes 100k or 100,000. So it's just an abbreviation for 100,000. Now 1 million, that is 1m representing 1 million. Next thing that I would like to explain is that our no-teacher system actually comes from anti-matter dimensions. So I found it on their GitHub under format.javascript and you'll see if you ever take a look, ours is very similar. I basically just converted the JavaScript version to C sharp because obviously we're making our games in Unity and C sharp. This all looks very complex. So I will be sure to explain very thoroughly on how it all works. So let's hop to our method script. So this is kind of where we left off last time. So I'm going to be importing a bunch of methods and stuff to the script and I'm going to provide them all below. So I don't want to type this all out because there is truly a lot going on, but I'm going to explain everything very thoroughly. Okay, so I have imported everything and you're probably looking me like, oh my goodness, this looks crazy. I wasn't really expecting it to be this complicated. And yeah, it's quite a bit. So I will explain everything very briefly. Let's start with the three string lists I have created. So the first one is just the regular standard notation. So you have 1,000 million, billion, trillion, et cetera, and it goes all the way down to Centilion. So these are the standard abbreviations or prefixes. Next, we have a list of a list of strings. So there are three different ones and each of these has their own definition. These are for larger numbers. So I honestly can't give you which one this one is or this one. I can't really point those out, but just know that these are for bigger numbers. And this one down here is for even bigger numbers. It's for joining multiple prefixes into one big thing that makes sense. Okay, next is this get abbreviation method. So I have commented a pretty good thoroughly explained example in here and let's just run through it real quick. So let's say that our exponent is 300. So that's what this variable is exp. It's the exponent of the number. So for example, if you had 1.45 e 399, the exponent is 399 and 1.46 is the mantisa. So we're going to pass in our 300 in here. So for example, we're doing e 300. So our exponent is 300. So we're going to set our exponents to four 300 divided by three minus one, and we get 99. Now, I'm going to be explaining this and I can't tell you how this works or why it works because I don't really know much about this. But but I'll do my best. So we create a local variable. It's an int and we call it index two. And we create a local list string object here. And we basically are looking through our standard prefixes, which is here. And we start from the first list that'll be right here. And we're going to put in our exponent mod 10. And we cast as an int. So since our exponent is 99, 99 mod 10 is nine. So we basically look for the ninth. And that will be n right here. So that's the ninth index. So we have n. And we set prefix to a brand new list. And it's just going to contain n because we're only looking for one string inside our standard prefixes. Next, we're going to move on to this while loop. So we have our exponent, which is 99. So while exponent is greater than 10, nine and eight is greater than 10, which we're going to go through it. We are going to set exponents to our floor, exponent divided by 10. So basically, it's going to go from 99 to nine. So if you don't know what floor is, is we're basically rounding it down. So basically, it'll go from 99 to 9.9. And we're going to floor it. So we're going to round it down. And that'll become nine. Next, we want to add to this list that we've created above. And we're going to add our standard prefixes plus plus index to mod three. So basically, we're going to add one to index two before we even access it. So if index two is zero, which it is, we're going to add one, and then we're going to use it. So basically, we're just doing one mod three. So one month, three, that is one. So we're going to start looking at this list. And we're going to access the instance, our exponent is nine, nine, mod 10 is nine. And we cast that as an int. So we're going to look for nn. So that would be the ninth index. So since the exponent is now nine, which is less than 10, we are done with this while loop. And the end result is an end result of prefix is a list with two strings n and nn. All right. So now we want to set index two to floor index two divided by three. So one divided by three, we're going to floor it that is zero. So index two, we'll go back to zero. Next, we're going to iterate through this while loop. So prefix dot count mod three is not equals zero. So prefix count right now is two, we have n and capital NN. So two mod three is two and two is not equal to zero. So basically, we're just going to add an empty string to this prefix. Now to find out how many times it's actually going to run, we can simply just do three minus two mod three, and that equals one. So we're going to run through this while loop one time. And our goal with this is to have the prefix list have three strings inside of it. So so regardless of what happens above prefix dot count will always end up being three, it's going to have three strings inside of it. After this while loop, we create a local string variable and we're just going to set as an empty string. So we're going to be running through another while loop and this basically just joins everything all together. So um, so index two is zero. So index two is greater or equal than zero. That's true. So we're going to run through it. So first run, we're going to add basically since index two is zero, we're going to add prefix zero times three plus zero times three plus one. And then another one of zero times three plus two. And we're at the end of that, we're going to add standard prefixes to add index zero to ret. So to summarize that together, that is basically prefix is at index zero plus prefix at index one, index two, and then standard prefixes to add index zero, which again, I know, sorry, this is a tongue twister. We're basically adding n plus nn plus empty string plus another empty string. And now we get this empty string from standard prefixes to and that is right here. That is index zero. So I know I'm hopping around a lot. So I'm really sorry if it's really hard to keep track. I honestly didn't really know how this worked until I dove a little deeper before this video. We have our ret and that is going to be equal to capital N capital N, lowercase N. So after we do that, actually while we're doing that, we are subtracting index two by one after we access it. So index two is zero, and then we're going to subtract it by one. So we're still using zero in here, but index two will be negative one afterwards. And since it's negative one, the while loop stops. Last but not least is the final part. And this is when we have really big numbers. So yeah, this only occurs with bigger numbers. And most of the standard prefixes to have a dash at the end. So you can see here they are in that case, if rat, the string variable that we have here ends with a dash, we're basically going to crop it by one character. So that's what this slice method is here. I'm not going to really explain it. It's basically just a substring. So you're basically just cropping out a string and getting rid of the rest. So that's what this is. And after that, we'll just replace a bunch of strings with new strings. And as you can see, they're, they're stated here. So we'll be replaced with M and so on. You can see there's more here. So that is all the custom methods we'll need for the standard notation. Let's put it all together. So for the standard notation, there are two parts of the string that we're going to return. The first part is the actual number. And the second part is the abbreviation, which we have created above. Let's start with the number. So I'm going to create a string variable called number, we're going to get rid of this eventually and join it all together. But for now, just to keep it organized, I'm going to create this local variable. So the way we want things to display is something like this. We want to have 145,760,000, we want to display this as 145.760 million, something like that. You can have a space where you can leave a blank, whatever you want, but we want to display it something like this. So in order to get this number here into something like this, we basically just need to crop all of this and leave the first six digits. So to do that, we're going to divide our number by big double dot pal. And inside of this pal method, our two parameters, which will be 10 to the power of our second parameter is going to be the exponent. So it'll be number dot exponent. However, this is not going to display correctly at the moment. What it's going to do is that it's always going to have one number and then a decimal here. Instead, it should look like something like this if it was 132 million. So we basically want to increase this number every three decimals. So to do that, we're going to divide this exponent by three, we're going to floor this, and we're going to multiply it by three. And that is all we need to do. So next what we can do is wrap this in a parentheses and do dot two string of three. So we want to show three decimals. Now we have the number we need to get the abbreviation. So remember the standard notation list I showed you here, I am only going to use this standard notation for a certain amount of exponents because we do really don't need to be using this gate abbreviation for all numbers. So it'll save us some work. We have the raw strings right here. So might as well use them. So first we're going to check to see if our exponent is less than 303. Now the reason why is because this goes up to e 300 and 9.99999 e 302 basically e 303 will not work because this belongs to Centilian, which is e 300. So if we were to have 999 Centilian, then this will be valid. If it was 1000 Centilian, then we would have to have something here. And that's what get abbreviation does. Hopefully that makes sense. To make things simpler, we're going to be using the ternary operator to determine whether if our exponent is less than 303 or not. So if it is, we're going to be accessing the standard notation, and we're going to cast a set of ends because our exponent is not in it is a long inside of our standard notation list, we have 102 strings in here. And this can go up to e 302. So we basically need to divide that by three. And then we have 100. So in order to access these indexes, we basically need to divide the exponent by three and round it up. So what we need to do is have our exponent, we need to divide by three, every three digits. So it'll be a little weird when we do this. So first, we're going to take the number and the exponent, we're going to divide that by three. However, we want to do this every three digits. So we're going to subtract that by number exponents, mod three. So now that we have our standard notation, we have to use the gate abbreviation method for bigger numbers with an exponent bigger than 303. So we're going to put the colon and remember this is the ternary operator. So this is true. And this is false. So for the false, we're using our gate abbreviation. And for the parameter, this is our number exponent. And that's it. Now we can join these all together. So we're going to return our number string, plus the abbreviation string. That is all we need to do with this. Before we move along and test this out, I want to make this one million thing here. So basically, so if the number was within negative million and positive million, we were going to show it's full number instead of having the standard notation. So if our number is less than one million, which is one E six, and when the number is greater than negative one million, we're just going to return the full number. And we can do that by doing number dot two string, and then we'll have our format as F three. Now I want to show commas because I think they look cool. Big double do not support that. So we need to convert this into a double, which is no big deal because these are fine ranges for the double. So we're just going to do dot two double and then dot two string. And then we have our F three, we're going to change that to N three, which is our number formatting. Now in some cases, you may not want to see three decimals. So I'm going to add a parameter for our normal digits. This will be an int, and it's going to go inside of this format. So I'm going to convert this to string interpolation, replace the three with curly braces, and then throw in our normal digits variable. And that will look like that. So I just cleaned things up, I removed the curly braces, and now it's just a one liner. So this is all we need to do for our standard notation. This is all we need to do with our notation system. So in our controller script, we have an error, we have our notate here. It requires a parameter with for our normal digits. But let's say we don't want to put a normal digits, let's head back to our methods. So for normal digits, we can make this an optional parameter. So by default, I want this to be three digits, or maybe you can have zero, whatever you want, or whatever you think will be used more often. I'm going to put three digits because I just like them that way. But if you end up wanting to put in seven decimals, two decimals, one decimal, et cetera, or is even zero decimals, then you can put in your own integer parameter in here. But I'm going to be using three decimals. So I'm going to leave that blank. Alright, so now let's go give this a shot. So right now we have 170 flasks, and it's just going to keep going up. So let's just keep incrementing this number. So right now we have 1000. Oh, I went a little too fast. You see, we have the comma here now. So it looks kind of nice, instead of having just one big number without any, you know, spacing makes it a little hard to read. So next, if we go to the millions, we have M seven, eight, nine, 10. Okay, let's just keep going. Let's go to 222. So we have TST, let's go to 300. We see NNN, like we saw before, 303. And we have Centilion. So actually, my bad, I meant to say that the limit is 305. And if we decide to keep going 3000, you could see we have some spacing going on here. So we can keep going on. You can see just, it gets very complex very quickly. So um, yeah, that's unreadable. At this point, you want to use scientific notation. If you don't, then you're stupid. So I hope you guys found this video helpful. And if you did, and if you enjoyed this one, make sure you leave a like, subscribe to my channel, or if you're new around here and turn on the bell for future notifications for videos and live streams. I will be seeing you guys out of said 5.2 and that will be on scientific notation. So stay tuned for that. Hope you guys have a great day or night. Thank you for watching. Peace.