The Elder Scrolls Forums

TES Construction Set and Plugins >> General TES Construction Set

Pages: 1
one_gundam_war
Acolyte

Reged: 04/19/03
Posts: 103
Loc: Wayrest
A way to round a value up or down?
      #2944229 - 08/18/04 02:37 PM

Okay, I just made something which will allow a bit of variation in the reward. Basically I used random for a value from 0-25, divided that by 100 (for a percent), and then multiply the reward per item by said value.

But then I realized that there would be a slight problem. The small bits leftover after this does it's work.

So is there a way to have a number round up or round down? I really don't think the game will like a reward of 53.249325230948214 gold

Post Extras: Print Post   Remind Me!   Notify Moderator  
Mode_Locrian
Diviner

Reged: 10/07/02
Posts: 2084
Loc: Bjornholm, Rykith Lowlands Region
Re: A way to round a value up or down? [Re: one_gundam_war]
      #2944325 - 08/18/04 03:21 PM

I'm pretty sure the game will round it automatically for you.

Otherwise, just make a short variable and store the random number into this variable after you're done calculating it. It won't round the number, but it will just truncate everything after the decimal point (e.g. 5.84362718 becomes 5).

--------------------
My Website
Bards of Vvardenfell Thread (New Info 8/15/04)


Post Extras: Print Post   Remind Me!   Notify Moderator  
one_gundam_war
Acolyte

Reged: 04/19/03
Posts: 103
Loc: Wayrest
Re: A way to round a value up or down? [Re: Mode_Locrian]
      #2944345 - 08/18/04 03:32 PM

works for me

Thanks.

Post Extras: Print Post   Remind Me!   Notify Moderator  
The_Silent_Pyro
Acolyte

Reged: 08/15/04
Posts: 124
Loc: Red Mountain
Re: A way to round a value up or down? [Re: one_gundam_war]
      #2944851 - 08/18/04 06:10 PM

If you want it to be rounded, do the previously mentioned method but have it add .5 to the number first. That will allow it to round up if the number ends in .5 or higher, and if not, it'll leave the number as is.

--------------------
Never laugh at a live dragon.
--Bilbo Baggins, There and Back Again: a Hobbit's Tale (a.k.a. The Hobbit)

Nerds rule the world. No one else knows it yet.

Post Extras: Print Post   Remind Me!   Notify Moderator  
Klinn
Diviner

Reged: 11/19/02
Posts: 2319
Re: A way to round a value up or down? [Re: The_Silent_Pyro]
      #2947228 - 08/19/04 12:40 PM

Just to be really finicky about this , adding .5 to all numbers will lead to an uneven distribution of results. All numbers which end with exactly ##.5 will always be rounded up. For even distribution, half should be rounded down and half should be rounded up. To avoid this, you can use a procedure such as: "add 0.4999999 to all even numbers, add 0.5 to all odd numbers"

In practice, for Morrowind scripting, this is not needed. If you're venturing into the wooly world of statistics, it becomes more important.

...Klinn


Post Extras: Print Post   Remind Me!   Notify Moderator  
cyran0
Initiate

Reged: 06/04/04
Posts: 58
Re: A way to round a value up or down? [Re: Klinn]
      #2949233 - 08/19/04 10:50 PM

With or without, adding the 0.5 is a sweet trick

Post Extras: Print Post   Remind Me!   Notify Moderator  
Pages: 1


Extra information
1 registered and 2 anonymous users are browsing this forum.

Moderator:  Umrahel, Freddo, Pete, Hungry Donner, Attrebus, Miltiades, tegger 

Print Thread

Permissions
      You cannot start new topics
      You cannot reply to topics
      HTML is disabled
      UBBCode is enabled

Rating:
Thread views: 55

Rate this thread
 
Jump to

The Elder Scrolls Homepage

*
UBB.threads™ 6.3

Click for Privacy Statement 2003 Bethesda Softworks LLC, a ZeniMax Media company. All Rights Reserved.
PRIVACY POLICY | TERMS & CONDITIONS | LEGAL INFORMATION | CONTACT US