Hello, I make a prototype clicker game as a school project and I am wondering if it’s possible to store very small float numbers in UE4. Trying to store numbers like 0.0000001 will automatically transform to 0.0. Is it possible to override this and allow the engine to store very small accurate numbers?
I don’t think that it is possible because the float data types are hard defined for the engine, as far as I know.
In c++ you might have the possibility to use other types but you might run into issues.
I would rather multiply values or directly use integer because it has no rounding issues, like floats.
Do you really really really need so many decimals? Decimals are often not the best solution when developing.
I tried using int64 but it doesn’t allow me to divide them or multiply them with floats. Basically, if I want to use int64 I have to only use int64 and nothing else and it leads me to other problems. And because normal int doesn’t store very high numbers I thought maybe I could use decimals and do some workaround.
You will come to some max values with every basic datatype eventually. This is also a common problem in business software.
I made a workaround where I display the Millions, billion, etc using only numbers between 1-1000 combined with counters that count how many times it reached 1000. 1 time = K. 2 times= M. 3 times=B etc. That way I can use integers and floats without the danger of maxing out. I have tested my system and it works flawlessly until the billions where it starts to round the floats. I divide 1 with 1000 * X (X the times it reached 1000) and then multiply it with the number I want to add/remove. So if my currency is at millions and I want to add to it 100 using this calculation it will Instead add 0,000100 while displaying 1,000100 M (Even though I don’t want to display the whole number I still want to exist in the background with perfect accuracy). 1.000 will become instead 0,1 etc. Though this can work only in perfect float accuracy with no rounding. Thus reaching my original question of the complete float accuracy.
I like that.
I think I have found the solution. The BP doesn’t support double variables. I need to write code in c++ if I want to use precise calculations.
To quote will smith: “that’s hot”
My previous statement was wrong. It seems that the best way to represent big numbers is by using strings and arrays. Converting strings to arrays of single digits and calculating based on the length can give you the ability to reach astronomically high numbers.
Oh this thread is killing me… Don’t store numbers using strings, that’s some JSON ■■■■.
Why not just use big ints for both the whole number and the fraction, and re-combine them when needed? @anonymous_user_2b77ac2e your system with M and B and all is kinda reinventing floats but in a wacky way.
If you do absolutely need fully arbitrary precision, yeah strings can serve as a stand in, but it’s never the ideal solution.
I think I saw someone creating a Marketplace product called Double which can store a far more precise float that can store that number range.
Yes, it was too stupid of me to think that was a viable solution. What I came up with is making an int array to store numbers. In index 0: hundred, index 1: thousands, index 2: millions, etc. If the numbers on thousands reach 1000 or over I remove 1000 and add 1 on the next index and via versa. Also is made so the numbers that will be added never reach more than 1000 by using a counter to be used to determine in what index to add the number. If I want to add 5 mills I won’t have to store the whole number but just the number 5 and the counter 2. That way it will go in the index 2 and add 5.
Usually, because string is avaliablen in BP while bigint or anything aside integer isn’t.
So you would get far more precision from using string.
There’s a few Rama nodes, and my code for a c++/BP String double concoction floating around this forum somewhere - unless they were lost in one of the moves.
Regardless. Usually if you need more precision than a float allows for you are doing something you shouldn’t within the engine.
I don’t care what it is or how - you just shouldn’t be doing it in this engine.
There’s a billion other solutions that actually support doubles - including ue5 apparently…