Solved

rounding down function?

Posted on 2003-10-22
7
254 Views
Last Modified: 2013-12-24
i have the following two variables that are both integers.

1. points
2. entries

#1, points has an initial value of 0.
#2, entries has an initial value of 1.

i want to make it so that for every 25 points, entries goes up by 1.

is there a cold fusion function that will round down.

meaning if they have 77 points, that would come out to (77/25) + 1 = 4.08 entries,
but i need it to come out as 4 entires. the + 1 is there because of the entries variable starts out at 1.

0
Comment
Question by:sagardeo
7 Comments
 
LVL 3

Accepted Solution

by:
SewellM earned 200 total points
ID: 9599975
#int((77/25) + 1)# would return 4.

The int() function only returns the integer part of the value.  No rounding.

Michael
0
 
LVL 9

Assisted Solution

by:CFDevHead
CFDevHead earned 150 total points
ID: 9599981
if you use #round(evaluate( (77/25) + 1))#
the answer will be 4

let me know if this helps.
0
 
LVL 9

Assisted Solution

by:CFDevHead
CFDevHead earned 150 total points
ID: 9600005
int(4.5) will output 4
and
round(4.5) will output 5
0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 

Author Comment

by:sagardeo
ID: 9600016
would the Fix function also work?
0
 
LVL 9

Assisted Solution

by:CFDevHead
CFDevHead earned 150 total points
ID: 9600167
the fix function works like this
#fix(4.5)#=4
0
 
LVL 17

Assisted Solution

by:anandkp
anandkp earned 125 total points
ID: 9600764
u have 4 functions fix, cileing, int & round

go for int - if u always want integer value
go for fix - if u want least integer value
go for cieling - if u want the next integer value
go for round - if u plan to round of to nearest integer

ur call :)

Cheers
Anand
0
 
LVL 10

Assisted Solution

by:Mause
Mause earned 25 total points
ID: 9605789
you can also do this:

<cfset result = (77 \ 25)>
result will be 3

And ofcourse

<cfset rest = (77 mod 25)>
rest will be  2

Mause
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question