Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently January 10th, 2025, 5:14 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Script to round number results
PostPosted: August 26th, 2006, 8:33 pm 
Offline
Godlike
Godlike

Joined: November 11th, 2004, 1:18 pm
Posts: 1213
Location: New York
Opus: Opus Pro 9.75
OS: Windows 10 Pro 64 bit
System: Core i7, 16G RAM, Nvidia 640GT (desktop), plus Windows 10 and Android tablets
Hi

Update (added later): Found a wonderful action called "Round" which does exactly what I was inquiring about below, answering my own question.

I'm trying to figure out how to display a total using rounded numbers. Currently, the scripting math creates a total score which has several decimal places. I'd like to simply display it as a whole number rounded up or down based on rounding rules to the nearest whole number.

Since this is a Flex pub, there are some limitations to data storage, but basic scripts seem to work OK.

Can anyone suggest a script to round the total to a whole number?

Any help would be appreciated.

Kind Regards,

_________________
Stephen


For this message Stephen has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: August 26th, 2006, 10:43 pm 
Offline

Joined: November 3rd, 2004, 4:12 pm
Posts: 173
Location: UK
Hi Stephen

You can use math.floor in your script (e.g. score_total = math.floor) to round the figure down and avoid decimal points. Or maybe this is what you've discovered.

Regards

Roger


For this message Roger Dunton has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject:
PostPosted: August 26th, 2006, 11:13 pm 
Offline
Godlike
Godlike

Joined: November 11th, 2004, 1:18 pm
Posts: 1213
Location: New York
Opus: Opus Pro 9.75
OS: Windows 10 Pro 64 bit
System: Core i7, 16G RAM, Nvidia 640GT (desktop), plus Windows 10 and Android tablets
Thanks Roger.

I hadn't tried that, since I found a standard action called "round" in the programming tab>variables.

I can keep the scripting you've suggested in mind for when a situation may call for it.

Thanks again.

Kind Regards,

_________________
Stephen


For this message Stephen has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: August 27th, 2006, 1:34 am 
Offline

Joined: October 26th, 2004, 1:26 pm
Posts: 262
Hi Stephen,

You can try the Math.round() function. It will round up/down to the closest whole number.

_________________
Cheers,
Steve


For this message Steve H has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: August 27th, 2006, 2:04 am 
Offline
Godlike
Godlike

Joined: November 11th, 2004, 1:18 pm
Posts: 1213
Location: New York
Opus: Opus Pro 9.75
OS: Windows 10 Pro 64 bit
System: Core i7, 16G RAM, Nvidia 640GT (desktop), plus Windows 10 and Android tablets
Thanks Steve.

I appreciate the options, since each may be needed for a different set of challenges.

As usual, I'm impressed with Opus's versatility in achieving results.

Kind Regards,

_________________
Stephen


For this message Stephen has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: August 27th, 2006, 8:17 am 
Offline

Joined: October 26th, 2004, 1:26 pm
Posts: 262
Quote:
<< As usual, I'm impressed with Opus's versatility in achieving results. >>


Hi Stephen,

I agree how excellent Opus is! :) I am continually learning OpuScript and after reading Roger's reply, it prompted me to explore more about 'rounding', and I see these options...

Math.ceil() //rounds a number up
Math.floor() //rounds a number down
Math.round() //rounds a number to the nearest number

Next.round() //hehe, only kidding... your shout to buy the next round! :lol:

_________________
Cheers,
Steve


For this message Steve H has been thanked by : mackavi


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 85 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group