COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

Round UP Up in FMP9

• Email
• Follow

```Is there a simple calculation that will always Round Up to the next whole
number.

Such that 7 divided by 3 results in 3 rather than the normal rounded result
of 2.

Object is a calculation that derives material to purchase but answer must
always be a complete unit even if only 2 tenths of a unit is required.

John G.

```
 0
Reply green1979 (15) 8/5/2008 8:59:24 AM

See related articles to this posting

```In article
<4898165f\$0\$24178\$5a62ac22@per-qv1-newsreader-01.iinet.net.au>,
"John G" <green@ozemail.com.au> wrote:

> Is there a simple calculation that will always Round Up to the next whole
> number.

If(num > Int(num), Int(num) + 1, num)

--
"Harry?" Ron's voice was a mere whisper. "Do you smell something ... burning?"
- Harry Potter and the Odor of the Phoenix
```
 0
Reply uce3 (3722) 8/5/2008 11:11:14 AM

```On Tue, 05 Aug 2008 07:11:14 -0400, Gregory Weston wrote:
>  In article
>  <4898165f\$0\$24178\$5a62ac22@per-qv1-newsreader-01.iinet.net.au>,
>   "John G" <green@ozemail.com.au> wrote:
>
> > Is there a simple calculation that will always Round Up to the next whole
> > number.
>
>  If(num > Int(num), Int(num) + 1, num)

Does this work for negative numbers?

- 5.5 -> is int(num) then -6 (would compute ok as -5) or -5 (which would
return -5.5)

How about
int(num) + if(num ≠ int(num), 1)
.... looks ok for a first glance but might return -4 instead :-(

```
 0
Reply t-use (418) 8/5/2008 11:28:30 AM

```"Gregory Weston" <uce@splook.com> wrote in message
news:uce-F9B5A1.07111405082008@newsclstr03.news.prodigy.net...
> In article
> <4898165f\$0\$24178\$5a62ac22@per-qv1-newsreader-01.iinet.net.au>,
> "John G" <green@ozemail.com.au> wrote:
>
>> Is there a simple calculation that will always Round Up to the next whole
>> number.
>
> If(num > Int(num), Int(num) + 1, num)
>
> --
> "Harry?" Ron's voice was a mere whisper. "Do you smell something ...
> burning?"
>   - Harry Potter and the Odor of the Phoenix

Thanks,
I should think more but Math 101 was back in the fifties.

John G.

```
 0
Reply green1979 (15) 8/5/2008 11:32:03 AM

```On Aug 5, 2:59 am, "John G" <gr...@ozemail.com.au> wrote:
> Is there a simple calculation that will always Round Up to the next whole
> number.
>
> Such that 7 divided by 3 results in 3 rather than the normal rounded result
> of 2.
>
> Object is a calculation that derives material to purchase but answer must
> always be a complete unit even if only 2 tenths of a unit is required.
>
> John G.

The function you're looking for is named: Ceiling()

G
```
 0
Reply grip (545) 8/5/2008 2:13:52 PM

```In article <slrng9geau.l8i.t-use@ID-685.user.individual.de>,
Martin Trautmann <t-use@gmx.net> wrote:

> On Tue, 05 Aug 2008 07:11:14 -0400, Gregory Weston wrote:
> >  In article
> >  <4898165f\$0\$24178\$5a62ac22@per-qv1-newsreader-01.iinet.net.au>,
> >   "John G" <green@ozemail.com.au> wrote:
> >
> > > Is there a simple calculation that will always Round Up to the next whole
> > > number.
> >
> >  If(num > Int(num), Int(num) + 1, num)
>
> Does this work for negative numbers?

A fair question. My use of > means that it won't work with negative
numbers. A bit of a deviation from the original post since the OP was
looking to round up quantities of ordered materials. Anything less than
zero would be anomalous, I'd think.

> - 5.5 -> is int(num) then -6 (would compute ok as -5) or -5 (which would
> return -5.5)
>
> How about
>   int(num) + if(num ≠ int(num), 1)
> ... looks ok for a first glance but might return -4 instead :-(

My biggest issue with this is that equality tests with some numeric
representations can be a bit fidgety. I have no idea what FMP uses
internally to store numbers so I went with a solution that's reliable in
general given the reasonable-to-me assumption that the input will always
be >= 0.

--
"Harry?" Ron's voice was a mere whisper. "Do you smell something ... burning?"
- Harry Potter and the Odor of the Phoenix
```
 0
Reply uce3 (3722) 8/5/2008 4:46:01 PM

```
"Grip" <grip@cybermesa.com> wrote in message
news:9efc7dc2-df74-44b2-8ad6-ee65121fe262@m44g2000hsc.googlegroups.com...
> On Aug 5, 2:59 am, "John G" <gr...@ozemail.com.au> wrote:
>> Is there a simple calculation that will always Round Up to the next whole
>> number.
>>
>> Such that 7 divided by 3 results in 3 rather than the normal rounded
>> result
>> of 2.
>>
>> Object is a calculation that derives material to purchase but answer must
>> always be a complete unit even if only 2 tenths of a unit is required.
>>
>> John G.
>
> The function you're looking for is named: Ceiling()
>
> G

Thanks for that. I would never have guessed Ceiling() was just the function
I needed and of course I would have to take care of the way it only Rounds
UP, ie negative numbers get smaller.
I must study the Help file more in my Spare? time.

John G.

```
 0
Reply green1979 (15) 8/5/2008 11:30:35 PM

```"Martin Trautmann" <t-use@gmx.net> wrote in message
news:slrng9geau.l8i.t-use@ID-685.user.individual.de...
> On Tue, 05 Aug 2008 07:11:14 -0400, Gregory Weston wrote:
>>  In article
>>  <4898165f\$0\$24178\$5a62ac22@per-qv1-newsreader-01.iinet.net.au>,
>>   "John G" <green@ozemail.com.au> wrote:
>>
>> > Is there a simple calculation that will always Round Up to the next
>> > whole
>> > number.
>>
>>  If(num > Int(num), Int(num) + 1, num)
>
> Does this work for negative numbers?
>
> - 5.5 -> is int(num) then -6 (would compute ok as -5) or -5 (which would
> return -5.5)
>
>
> How about
>  int(num) + if(num ? int(num), 1)
> ... looks ok for a first glance but might return -4 instead :-(
>
Because it is always a negative numer I changed the Greater than to Less
than and changed the Pplus1 to Minus one and it all worked just as desired.
Then put a minus in front of the lot so when the resulting order was printed
it was just a posative number to order.

There are Rounds and Case statements etc and I think it is now the longest
calculation I have ever attempted in FMP

-If(Case(Round (Total110/2000;1)<0;(Round (Total110/2000;1));"")  <
Int(Case(Round (Total110/2000;1)<0;(Round
(Total110/2000;1));""));Int(Case(Round (Total110/2000;1)<0;(Round
(Total110/2000;1));"")) - 1;Case(Round (Total110/2000;1)<0;(Round
(Total110/2000;1));""))

All the fields are Globals that I did not name very well sorry.

This is a great use of News Groups in a world where one may never actually
speak to someone who understands the question.

Thanks again to all for the help.

John G.

```
 0
Reply green1979 (15) 8/5/2008 11:43:34 PM

```> Thanks for that. I would never have guessed Ceiling() was just the function
> I needed

Ceiling and Floor are the standard mathematical names for those
functions, and are available in most programming environments under
those names. For more info:

http://en.wikipedia.org/wiki/Ceiling_function

> and of course I would have to take care of the way it only Rounds
> UP, ie negative numbers get smaller.

Ceiling always rounds 'up'
Floor always rounds 'down'.

If, on the other hand, you want a function that always rounds 'away
from zero' then:

sign(n) * ceiling(abs(n))

And for completeness, if you want a function that always rounds
'towards' zero, than:

int(n)

-cheers,
Dave

```
 0
Reply db.porsche (396) 8/6/2008 12:10:07 AM

```"Martin Trautmann" <t-use@gmx.net> wrote in message
news:slrng9geau.l8i.t-use@ID-685.user.individual.de...
> On Tue, 05 Aug 2008 07:11:14 -0400, Gregory Weston wrote:
> >  In article
> >  <4898165f\$0\$24178\$5a62ac22@per-qv1-newsreader-01.iinet.net.au>,
> >   "John G" <green@ozemail.com.au> wrote:
> >
> > > Is there a simple calculation that will always Round Up to the next
> > > whole
> > > number.
> >
> >  If(num > Int(num), Int(num) + 1, num)
>
> Does this work for negative numbers?
>
> - 5.5 -> is int(num) then -6 (would compute ok as -5) or -5 (which would
> return -5.5)
>
>
> How about
>  int(num) + if(num ? int(num), 1)
> ... looks ok for a first glance but might return -4 instead :-(

If you want numbers to round up with negative getting closer to 0, then
I think this this one works:

Round(NumField + 0.4, 0)

This means -5.2 rounds up to -5

But, if you want negative numbers to round down (further from 0), then
I think this one works instead:

Sign(NumField) * Round(Abs(NumField) + 0.4, 0)

With this one, -5.2 will be rounded to -6.

In both cases 0 is still rounded to 0.

Helpful Harry
Hopefully helping harassed humans happily handle handiwork hardships  ;o)
```
 0
Reply helpful_harry (1511) 8/6/2008 12:57:24 AM

```On Wed, 06 Aug 2008 12:57:24 +1200, Helpful Harry wrote:
>  If you want numbers to round up with negative getting closer to 0, then
>  I think this this one works:
>
>     Round(NumField + 0.4, 0)
>
>  This means -5.2 rounds up to -5

How about 5.01? You'd have to use
0.499999999999999999999999999999999999999999999999 instead...

(which might fail not only for even more decimal digits, but my fail due
to an internal rounding up to 0.5 as well - and will assume 0.5 for very
high numbers).

>       Sign(NumField) * Round(Abs(NumField) + 0.4, 0)

Sign is a trivial solution -  I'd like a more elegant one :-)

- Martin
```
 0
Reply t-use (418) 8/6/2008 8:34:36 AM

```On Aug 6, 1:34=A0am, Martin Trautmann <t-...@gmx.net> wrote:
> On Wed, 06 Aug 2008 12:57:24 +1200, Helpful Harry wrote:
> > =A0If you want numbers to round up with negative getting closer to 0, t=
hen
> > =A0I think this this one works:
>
> > =A0 =A0 Round(NumField + 0.4, 0)
>
> > =A0This means -5.2 rounds up to -5
>
> How about 5.01? You'd have to use
> 0.499999999999999999999999999999999999999999999999 instead...
>
> (which might fail not only for even more decimal digits, but my fail due
> to an internal rounding up to 0.5 as well - and will assume 0.5 for very
> high numbers).
>
> > =A0 =A0 =A0 Sign(NumField) * Round(Abs(NumField) + 0.4, 0)
>
> Sign is a trivial solution - =A0I'd like a more elegant one :-)
>
> - Martin

As I wrote elsewhere in this thread:

If you want a function that always rounds 'away
from zero' then:

sign(n) * ceiling(abs(n))

If you want a function that always rounds

'towards' zero, than:

int(n)

-regards,
Dave
```
 0
Reply db.porsche (396) 8/6/2008 5:57:58 PM

11 Replies
55 Views

Similar Articles

12/12/2013 7:49:19 PM
[PageSpeed]

 Reply:

Similar Artilces:

Rounding
This is the part of the problem that I want to solve..........The rounding rules forsales tax are that for a tax rate of n%, a shelf price of p contains(np/100 rounded up to the nearest 0.05) amount of salestax................How to round up the sales tax? Amol wrote:> The rounding rules for sales tax are that for a tax rate of n%,> a shelf price of p contains (np/100 rounded up to the nearest 0.05)> amount of sales tax................> > How to round up the sales tax?Google? Wikipedia? Rounding is something I did in third year in school, Ithink, what exactly is your problem wit...

Rounding Up
I am trying to get FMP to round up a number to the next whole. Example: You are making a 2,323 mile trip and your company buys you a hotel room every 450 miles for the amount of \$80.00. 2323/450 returns a value of 5.16. I want to round this number to 6 Also, if the mileage is <450 then it should return a "0" Bear in mind that the mileages are always different, the breakpoint miles are always different and the dollar amounts are always different. Thanks in advance for all your help ( Int(Mileage) + (Int(Mileage) <> Mileage)) )* (Mileage >449) -- John Weinshel Datag...

Dimension Rounding?
I have dimensioned a feature and it shows as 1.745. When I change the Primary Unit Precision to 2 deciaml places the dimension shows as 1.74. I would expect to see 1.75. But anyway I've searched all through the Options and the help file and I can't find anyway to change the 'rounding' behavior. Am I missing something? -- Jeff Show the dimension with four or five decimal places and you'll probably see why (it's probably 1.7449 or something). Eric Not Necessarily Me wrote: > I have dimensioned a feature and it shows as 1.745. When I change the > Primary U...

Rounding a Number
How can I round a number to the nearest n decimal places? I know the basic algorithm is to multiply by 10 to the power n, add 0.5, floor it (drop the digits after the decimal point, and keep the integer), and then divide by 10 to the power n. However, I don't know how to cut off the digits after the decimal point. Thanks. -- Mike Lepore, email delete the 5 >>>>> "ML" == Mike Lepore <lepor5e@bestweb.net> writes: ML> How can I round a number to the nearest n decimal places? ML> I know the basic algorithm is to multiply by 10 to the power n, ...

rounding off in awk
I am using the following awk script: BEGIN { OFMT = "%10.4f"; } END { print "Test Starting"; l1 = 675.5 l2 = 306.9 l3 = 613.8 l4 = 135.1 l5 = 82.5 l6 = 135.1 l7 = 400 l8 = 82.5 t = 17.5; t1 = l1 * t / 100; t2 = l2 * t / 100; t3 = l3 * t / 100; t4 = l4 * t / 100; t5 = l5 * t / 100; t6 = l6 * t / 100; t7 = l7 * t / 100; t8 = l8 * t / 100; print "t1 = " t1; print "t2 = " t2; print "t3 = " t3; print "t4 = " t4; print "t5 = " t5; print "t6 = " t6; print "t7 = " t7; print "t8 = " t8; total = 0; t...

Rounding problem
Hi there, If I use round(1.95583, 2); I would get the perfect result of 1.96 for my currency. But if I round(1.9) I would just get 1.9. Is there a function or solution so it would always round with 2 digits for a currency? thnxz... Roger Godefroy <godefroy@(nospam)home.nl> wrote: > Hi there, > > If I use round(1.95583, 2); I would get the perfect result of 1.96 for my > currency. But if I round(1.9) I would just get 1.9. Is there a function or > solution so it would always round with 2 digits for a currency? > > thnxz... Check out number_format() http://php...

Rounded shapes
I have been playing around with the Graphics2D drawing tools. I discovered they behave very much like PostScript. I also discovered OpenGL. It too seems to work much the same way. I set myself the task of drawing a VGA connector. It has a rounded D shaped shell. I wonder if there is something I have missed that would make it easy to round the corners. I discovered that BasicShape control of caps and joins just rounds to half the radius of a line. I want a much bigger radius. I discovered curveto but the docs don't in any way hint how to get the two control points to get t...

rounding mode
I would like to investigate why i get slightly different results for a piece of Fortran 95 code that I translated to Octave/Matlab. I would like to check if the differnce is due to differences in rounding. I don't know the default rounding mode for Octave/Matlab, but I know I can set it in Matlab using system_dependent('setround', foobar) My questions now are: What is the default rounding mode for Fortran 95? Searching for the string 'rounding mode' in the Fortran 95 standard didn't return me any results, which made me think this is compiler dependent... However, ...

postnormalizing before or after rounding
Hi, In a floating-point division (based on IEEE 754), I wonder whether the final quotient should be rounded after postnormalization or before. If after, it seems that the Ercegovac-Lang "one-the-fly rounding" scheme doesn't comply this necessity because it doesn't check whether quotient's most significant bit is zero or not. Is that right ? cheers Hooman In article <fe061712.0406272158.77e3dad5@posting.google.com>, nhooman@eleceng.adelaide.edu.au (Hooman) writes: |> |> In a floating-point division (based on IEEE 754), I wonder whether the |> final quot...

Rounded Rectangle...
I want a new layer on my image that is a rounded rectangle 70px by 120px but I only want it to be like a frame so to speak. I want this to be 1px think with the interior clear. How do I do this in CS2? David Boothe wrote: > I want a new layer on my image that is a rounded rectangle 70px by 120px > but I only want it to be like a frame so to speak. I want this to be > 1px think with the interior clear. How do I do this in CS2? Perhaps asking on a HTML/CSS group will prompt some replies? ...

rounding down numbers
hi, I have a variable containing numbers and I need to round these down to increments of 500. example of the data file currently: number 534 1499 2200 output I need to get: new_number 500 1000 2000 Thanks Wes or you could use the round-function? newvar = ROUND(var-250, 500) ; /* -250 since since you're rounding down */ /LWn <wesley.greenhead@iclployalty.com> skrev i meddelandet news:550017f6-8132-439f-a9f1-cf873fd1855f@1g2000hsl.googlegroups.com... > hi, > > I have a variable containing numbers and I need to round these down to > increments of 500. > > ...

rounding to an integer
If I divided an integer by an integer how would I round the answer to the next whole number as using the Round() function doesn't seem to work. It returns 22 when the division equals 22.5 ? Cheers As seen below, my VB5 help says that CInt() rounds to the nearest even number, and Int() appears to do the same thing I think. Not sure why it hasn't been designed to just round to the nearest number. I wonder if there is an advantage to this? "When the fractional part is exactly 0.5, CInt and CLng always round it to the nearest even number. For example, 0.5 rounds to 0, and 1.5...

Rounding #2
In java is there a way to round a double to 2 decimal places for example money \$2.50 not \$2.502453651 Thank-you Rookie Rookie wrote: > In java is there a way to round a double to 2 decimal places for > example money \$2.50 not \$2.502453651 Hi Rookie, Check out Bigdecimal in java.math. An exampleprogram follows. Be sure to read: http://java.sun.com/j2se/1.3/docs/api/java/math/BigDecimal.html the part about BigDecimal.ROUND_HALF_UP or whatever roundmethod suits you is important to read, so you know what you are doing. (I never before was aware of all these roundmethods. Saying ju...

Rounding and Grouping
Perhaps someone can settle an arguement for me ? I have a set of data that I need to group together. SQL Script below. CREATE TABLE [dbo].[CommTransactions] ( [ID] [id_type] NOT NULL , [TransactionID] [id_type] NULL , [ClientID] [id_type] NULL , [AccountCode] [varchar] (10) NULL , [Amount] [float] NULL , [CreateDateTime] [datetime] NULL For the records I want to group the following applies. The ID is unique and distinct. The TransactionId is the same. The ClientId is the same. The AccountCode is different. The Amount will be the same. The CreateDateTime field is different by a few ...

Round window
Hi, does anybody have experiance with making round windows in Java. I use JWindow to get rid of the title bar, but I don't know how to change the shape of thw JWindow. Is it possible to achive it without accessing native OS functions? thx "Igor Buzatovi�" <igor.buzatovic@willevolve.com> writes: > Hi, does anybody have experiance with making round windows in Java. Please search an archive of this group. It has been discussed several times. /Thomas I found it, thx! "Thomas Weidenfeller" <nobody@eed.ericsson.invalid> wrote in message news:bej7th\$1o...

round()
Hello, can somebody explain this: expr round( 9.95 * 0.5 * 100.0 ) 497 expr round( [expr 9.95 * 0.5 * 100.0] ) 498 expr round(9.950000000000001 * 0.5 * 100) 498 - or is this a BUG? (is it fixed in newer versions??) (tcl/tk 8.4.11 on Linux) Thanks! Matthias Matthias Meier <meier@fuh.de> writes: > Hello, > > can somebody explain this: > > > expr round( 9.95 * 0.5 * 100.0 ) > 497 > > expr round( [expr 9.95 * 0.5 * 100.0] ) > 498 > > expr round(9.950000000000001 * 0.5 * 100) > 498 > > > - or is this a BUG? (is it fixed in newer vers...

Rounding #3
AI = analoginput('advantech',2) chan = addchannel(AI,0) set(AI,'TriggerChannel',chan) rate = 1000 Freq = setverify(AI,'SampleRate',rate) Zeit = 0.01 Abtasten = setverify(AI,'SamplesPerTrigger',Zeit*Freq) set(AI,'BufferingMode') start(AI) finish = getdata(AI) I got the following value. finish = 5.1425 What must I do that I have only 1 dezimal finish = 5.1 finish = (round(10*getdata(AI)))/10 should work ...

Round function
FM7 on OSX and XP. I'm working on a complicated invoicing system and am looking for the best way to calculate values to exactly two decimal places. I'm having trouble with the Round function. Right now when I Round a number to 2 decimal places, it only gives me those 2 places if the number has 2 or more decimal places, not if it has less. For instance if PaymentsReceived = \$47 Round((PaymentsReceived);2) = 47 (not 47.00) Likewise if calcTotalDue = calcTotal-PaymentsReceived and calcTotal = 47.93 and PaymentsReceived = 47.93 then Round(calcTotalDue) = 0 NOT 0.00 How can I get FM ...

Rounding double
Hi Does any body know, how to round a double value with a specific number of digits after the decimal points? A function like this: RoundMyDouble (double &value, short numberOfPrecisions) It then updates the value with numberOfPrecisions after the decimal point. Any help is appreciated. Thanks. md On Nov 22, 10:39 am, md <mojtaba.da...@gmail.com> wrote: > Hi > > Does any body know, how to round a double value with a specific number > of digits after the decimal points? > > A function like this: > > RoundMyDouble (double &value, short numberOfPrecisi...

rounding-off a number
dear friends, i want to apply dirac delta function .i.e.delta(t-T)=1 when t=T and 0 when t~=T.in my case some parameter I=10 when t=T and 0 when t~=T,and t=Toccurs only after certain interval. i coded it like: global I n=0.05;t0=0;tau=.05; h=0.1; for i=1:21 if t0==tau I=1;tau=tau+n; else I=0; end t0=t0+h; I1(1,i)=I; end the problem is everytime I1=zero vector pls let me know how can i do this correctly. thanx anindita anindita bhattacharjee wrote: > > > dear friends, > i want to apply dirac delta function .i.e.delta(t-T)=1 when t=T > and &...