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

Int precent

The section related to UnrealScript and modding. This board is for coders to discuss and exchange experiences or ask questions.
User avatar
Age
OldUnreal Member
Posts: 848
Joined: Sat Dec 29, 2007 5:25 pm

Int precent

Post by Age »

How to count precent (%) with two ints (integer)?
For example: 56 to 4082
For me it return always 0.
precent=float(56/4082)*100 returns 0 too.
Last edited by Age on Sun Nov 02, 2008 11:27 am, edited 1 time in total.
User avatar
Chaos13
OldUnreal Member
Posts: 951
Joined: Sat Feb 16, 2008 10:24 am

Re: Int precent

Post by Chaos13 »

Try
percent=float(int1*100)/float(int2);
Skydev = Chaos13 = Dimension4
User avatar
Bane
OldUnreal Member
Posts: 493
Joined: Sun Mar 03, 2002 6:32 pm

Re: Int precent

Post by Bane »

If you want to avoid floating point math, do (int1*100)/int2.

float(56/4082)*100 is 0 because 56/4082 is evaluated first, and that's 0. Converting that to a float and multiplying by 100 doesn't change anything.
Author of Hide and Seek mod, and the NALIBALL mod

Hide and Seek can be downloaded from:
http://HideNSeek.5u.com
User avatar
[§Ŕ] ŤhěxĐâŕkśîđěŕ
OldUnreal Member
Posts: 4425
Joined: Wed Sep 03, 2008 8:19 am

Re: Int precent

Post by [§Ŕ] ŤhěxĐâŕkśîđěŕ »

What's the difference between floating point and double floating point anyway?
User avatar
Bane
OldUnreal Member
Posts: 493
Joined: Sun Mar 03, 2002 6:32 pm

Re: Int precent

Post by Bane »

Precision. I'm not going to bother going into details, but a double has more storage and therefore can represent larger values and be more accurate.
Author of Hide and Seek mod, and the NALIBALL mod

Hide and Seek can be downloaded from:
http://HideNSeek.5u.com
User avatar
Chaos13
OldUnreal Member
Posts: 951
Joined: Sat Feb 16, 2008 10:24 am

Re: Int precent

Post by Chaos13 »

Single precision, called "float" in the C language family, and "real" or "real*4" in Fortran. This is a binary format that occupies 32 bits (4 bytes) and its significand has a precision of 24 bits (about 7 decimal digits).

Double precision, called "double" in the C language family, and "double precision" or "real*8" in Fortran. This is a binary format that occupies 64 bits (8 bytes) and its significand has a precision of 53 bits (about 16 decimal digits).
Skydev = Chaos13 = Dimension4
User avatar
[§Ŕ] ŤhěxĐâŕkśîđěŕ
OldUnreal Member
Posts: 4425
Joined: Wed Sep 03, 2008 8:19 am

Re: Int precent

Post by [§Ŕ] ŤhěxĐâŕkśîđěŕ »

Oh... I just knew that float is 32 bit and double is 64 bit lol.
User avatar
GreatEmerald
OldUnreal Member
Posts: 5347
Joined: Mon May 21, 2007 2:30 pm

Re: Int precent

Post by GreatEmerald »

Hmm, and in Pascal they are Real and Real64 IIRC.
Last edited by GreatEmerald on Wed Nov 05, 2008 9:08 pm, edited 1 time in total.
User avatar
[§Ŕ] ŤhěxĐâŕkśîđěŕ
OldUnreal Member
Posts: 4425
Joined: Wed Sep 03, 2008 8:19 am

Re: Int precent

Post by [§Ŕ] ŤhěxĐâŕkśîđěŕ »

I call them "float" and "double" because that's how it's called in Java and I know Java probably the most of all except VB and those simple languages. ^_^
User avatar
GreatEmerald
OldUnreal Member
Posts: 5347
Joined: Mon May 21, 2007 2:30 pm

Re: Int precent

Post by GreatEmerald »

Oops, I meant Real, what was I thinking lol. Fixed ;)
User avatar
[§Ŕ] ŤhěxĐâŕkśîđěŕ
OldUnreal Member
Posts: 4425
Joined: Wed Sep 03, 2008 8:19 am

Re: Int precent

Post by [§Ŕ] ŤhěxĐâŕkśîđěŕ »

Lmao Age you've misspelled "percent", you typed "precent".
User avatar
GreatEmerald
OldUnreal Member
Posts: 5347
Joined: Mon May 21, 2007 2:30 pm

Re: Int precent

Post by GreatEmerald »

How to count precent (%) with two ints (integer)?
For example: 56 to 4082
For me it return always 0.
precent=float(56/4082)*100 returns 0 too.
Yeap. Three times.
User avatar
Chaos13
OldUnreal Member
Posts: 951
Joined: Sat Feb 16, 2008 10:24 am

Re: Int precent

Post by Chaos13 »

How to count precent (%) with two ints (integer)?
For example: 56 to 4082
For me it return always 0.
precent=float(56/4082)*100 returns 0 too.

Well i think that if you could be a little more imaginative you could try moving the stuff and typecasts yourself in order to find a way that actually works. Lol :D
Skydev = Chaos13 = Dimension4

Return to “UScript Board”