For direct access use https://forums.oldunreal.com
It's been quite a while since oldunreal had an overhaul, but we are moving to another server which require some updates and changes. The biggest change is the migration of our old reliable YaBB forum to phpBB. This system expects you to login with your username and old password known from YaBB.
If you experience any problems there is also the usual "password forgotten" function. Don't forget to clear your browser cache!
If you have any further concerns feel free to contact me: Smirftsch@oldunreal.com

Truncating float returns

The section related to UnrealScript and modding. This board is for coders to discuss and exchange experiences or ask questions.
Post Reply
User avatar
gopostal
OldUnreal Member
Posts: 1005
Joined: Thu Jul 31, 2008 9:29 pm

Truncating float returns

Post by gopostal »

UEngine defaults float returns to six decimals. For example you would get the return of "3.333333" when the decimal repeats. Is there a simple way to truncate that return to one or two decimal places without having to convert to a string value and then parsing the string after the "."? I looked through the function list and I can't find anything.
I don't want to give the end away
but we're all going to die one day
User avatar
yrex .
OldUnreal Member
Posts: 273
Joined: Wed May 06, 2015 6:46 am
Contact:

Re: Truncating float returns

Post by yrex . »

int(x*100)/100, but it may introduce some error.
My work | contact: ampoyrex at wp dot pl
User avatar
gopostal
OldUnreal Member
Posts: 1005
Joined: Thu Jul 31, 2008 9:29 pm

Re: Truncating float returns

Post by gopostal »

Thank you y, this is exactly what I needed. I see the introduced error but it's slight enough that it works just fine.

BTW, in case this bubbles up in a google search here is how I was able to get to where I wanted to go...

Code: Select all

//Kills to Deaths Ratio computation (protects from divide-by-zero)
If(PRI.Deaths
Last edited by gopostal on Wed Sep 11, 2019 4:54 pm, edited 1 time in total.
I don't want to give the end away
but we're all going to die one day
User avatar
[]KAOS[]Casey
OldUnreal Member
Posts: 4497
Joined: Sun Aug 07, 2011 4:22 am
Location: over there

Re: Truncating float returns

Post by []KAOS[]Casey »

it's too bad fstring printf was never exposed to unrealscript, i use it all the time in native code
User avatar
gopostal
OldUnreal Member
Posts: 1005
Joined: Thu Jul 31, 2008 9:29 pm

Re: Truncating float returns

Post by gopostal »

Your posts came up in almost every google search I did trying to solve this. I admit I didn't understand what you were advocating for but now that I've dealt with the issue I see what you mean. There needs to be a better way to get from A to B on this, something native and much faster than code to truncate returns.
I don't want to give the end away
but we're all going to die one day
Post Reply

Return to “UScript Board”