Rounding numbers

  • Follow


Hi all,
I'm having some trouble understanding how to get the Round function to work
like I want it to.

A little background first:
On one of my layouts I have put fields that we fill in with the number of
hours we've used on a certain job, like:

Photography field: 1,20
Darkroom work: 2,15

A calculation adds these and puts the total of 3,35 in a field called, let's
say "NUMBER".

Now, I want the numbers rounded up to the nearest half, i.e 3,35 -> 3,50,
and 3,75 -> 4,00

I've made a display field that's supposed to show the rounded number (3,50)
and given this field the calculation:
Round(NUMBER;2)

(remember that my version differs from the US one and uses ";" instead of
"," as an separator)

and of course this shows me the correct value of 3,35, but I want it to show
me 3,50.

Now I've surfed and surfed and googled my brains out, but cant find out how
to set the field right.

Can anyone in here enlighten me on this subject.

Regards,
Henning

Norway

0
Reply Henning 6/2/2004 11:25:55 AM

This will work with all versions. If your using ver 7, I would think the 
new ceiling and floor functions would allow you more flexibility in 
solving this problem.

Case(
     NUMBER - Int(NUMBER) <= ,5; NUMBER + Mod( ,5 - Round( Mod( NUMBER; 
,5 ) ; 2 ) ; ,5 );
     NUMBER - Int(NUMBER) > ,5; Int(NUMBER) + 1 )

Michael Myett

Henning Sannerhaugen wrote:
> Hi all,
> I'm having some trouble understanding how to get the Round function to work
> like I want it to.
> 
> A little background first:
> On one of my layouts I have put fields that we fill in with the number of
> hours we've used on a certain job, like:
> 
> Photography field: 1,20
> Darkroom work: 2,15
> 
> A calculation adds these and puts the total of 3,35 in a field called, let's
> say "NUMBER".
> 
> Now, I want the numbers rounded up to the nearest half, i.e 3,35 -> 3,50,
> and 3,75 -> 4,00
> 
> I've made a display field that's supposed to show the rounded number (3,50)
> and given this field the calculation:
> Round(NUMBER;2)
> 
> (remember that my version differs from the US one and uses ";" instead of
> "," as an separator)
> 
> and of course this shows me the correct value of 3,35, but I want it to show
> me 3,50.
> 
> Now I've surfed and surfed and googled my brains out, but cant find out how
> to set the field right.
> 
> Can anyone in here enlighten me on this subject.
> 
> Regards,
> Henning
> 
> Norway
> 
0
Reply Michael 6/2/2004 12:12:49 PM


When you specify two decimal places in the Round function, as you did, it
won't round up to the half.  3.35 will stay 3.35.  You need to change
Round(NUMBER;2) to Round(NUMBER;1), then your examples will round
correctly.  However, they will not display the trailing zero.  You will
end up with 3.5 and 4 instead of 3.50 and 4.00.  If you need the trailing
zeros, you might consider a calculation field, text result, for display
that adds these back in.

Steve Brown


In article <BCE385E3.37D9%henning@liergrafiske.no>, Henning Sannerhaugen
<henning@liergrafiske.no> wrote:

>Hi all,
>I'm having some trouble understanding how to get the Round function to work
>like I want it to.
>
>A little background first:
>On one of my layouts I have put fields that we fill in with the number of
>hours we've used on a certain job, like:
>
>Photography field: 1,20
>Darkroom work: 2,15
>
>A calculation adds these and puts the total of 3,35 in a field called, let's
>say "NUMBER".
>
>Now, I want the numbers rounded up to the nearest half, i.e 3,35 -> 3,50,
>and 3,75 -> 4,00
>
>I've made a display field that's supposed to show the rounded number (3,50)
>and given this field the calculation:
>Round(NUMBER;2)
>
>(remember that my version differs from the US one and uses ";" instead of
>"," as an separator)
>
>and of course this shows me the correct value of 3,35, but I want it to show
>me 3,50.
>
>Now I've surfed and surfed and googled my brains out, but cant find out how
>to set the field right.
>
>Can anyone in here enlighten me on this subject.
>
>Regards,
>Henning
>
>Norway
0
Reply eyebrown 6/2/2004 12:13:16 PM

Thanks Michael,

I didn't understand a thing, but it worked like a charm.

Do you, or anybody else in here know of any sites covering operators and
functions for newbies like me (who develop allergic rashes when faced with a
string like this)


Henning

On 02-06-04 14:12, in article 5vjvc.13911$bD4.9520@nwrdny02.gnilink.net,
"Michael Myett" <mmyett@hotmail.com> wrote:

> This will work with all versions. If your using ver 7, I would think the
> new ceiling and floor functions would allow you more flexibility in
> solving this problem.
> 
> Case(
>    NUMBER - Int(NUMBER) <= ,5; NUMBER + Mod( ,5 - Round( Mod( NUMBER;
> ,5 ) ; 2 ) ; ,5 );
>    NUMBER - Int(NUMBER) > ,5; Int(NUMBER) + 1 )
> 
> Michael Myett
> 
> Henning Sannerhaugen wrote:


>> Hi all,
>> I'm having some trouble understanding how to get the Round function to work
>> like I want it to.
>> 
>> A little background first:
>> On one of my layouts I have put fields that we fill in with the number of
>> hours we've used on a certain job, like:
>> 
>> Photography field: 1,20
>> Darkroom work: 2,15
>> 
>> A calculation adds these and puts the total of 3,35 in a field called, let's
>> say "NUMBER".
>> 
>> Now, I want the numbers rounded up to the nearest half, i.e 3,35 -> 3,50,
>> and 3,75 -> 4,00
>> 
>> I've made a display field that's supposed to show the rounded number (3,50)
>> and given this field the calculation:
>> Round(NUMBER;2)
>> 
>> (remember that my version differs from the US one and uses ";" instead of
>> "," as an separator)
>> 
>> and of course this shows me the correct value of 3,35, but I want it to show
>> me 3,50.
>> 
>> Now I've surfed and surfed and googled my brains out, but cant find out how
>> to set the field right.
>> 
>> Can anyone in here enlighten me on this subject.
>> 
>> Regards,
>> Henning
>> 
>> Norway
>> 

0
Reply Henning 6/2/2004 12:48:07 PM

Round only rounds to decimal places, not to the nearest half, whole, 
etc. Try this:

Round(Number * 2;1) / 2.

Format the field to show two decimal places.
0
Reply Kevin 6/2/2004 1:47:49 PM

Your welcome.

I would start at www.databasepros.com lots of open source files to pick 
apart. Go to resources and search for calculations, should get you started.

If you prefer books go to amazon.com and search for FileMaker. There's a 
lot of good FM books out there but plenty of junk too, so read the 
reviews carefuly; they are generally on the mark.

Good luck.

Michael Myett

Henning Sannerhaugen wrote:

> Thanks Michael,
> 
> I didn't understand a thing, but it worked like a charm.
> 
> Do you, or anybody else in here know of any sites covering operators and
> functions for newbies like me (who develop allergic rashes when faced with a
> string like this)
> 
> 
> Henning
> 
> On 02-06-04 14:12, in article 5vjvc.13911$bD4.9520@nwrdny02.gnilink.net,
> "Michael Myett" <mmyett@hotmail.com> wrote:
> 
> 
>>This will work with all versions. If your using ver 7, I would think the
>>new ceiling and floor functions would allow you more flexibility in
>>solving this problem.
>>
>>Case(
>>   NUMBER - Int(NUMBER) <= ,5; NUMBER + Mod( ,5 - Round( Mod( NUMBER;
>>,5 ) ; 2 ) ; ,5 );
>>   NUMBER - Int(NUMBER) > ,5; Int(NUMBER) + 1 )
>>
>>Michael Myett
>>
>>Henning Sannerhaugen wrote:
> 
> 
> 
>>>Hi all,
>>>I'm having some trouble understanding how to get the Round function to work
>>>like I want it to.
>>>
>>>A little background first:
>>>On one of my layouts I have put fields that we fill in with the number of
>>>hours we've used on a certain job, like:
>>>
>>>Photography field: 1,20
>>>Darkroom work: 2,15
>>>
>>>A calculation adds these and puts the total of 3,35 in a field called, let's
>>>say "NUMBER".
>>>
>>>Now, I want the numbers rounded up to the nearest half, i.e 3,35 -> 3,50,
>>>and 3,75 -> 4,00
>>>
>>>I've made a display field that's supposed to show the rounded number (3,50)
>>>and given this field the calculation:
>>>Round(NUMBER;2)
>>>
>>>(remember that my version differs from the US one and uses ";" instead of
>>>"," as an separator)
>>>
>>>and of course this shows me the correct value of 3,35, but I want it to show
>>>me 3,50.
>>>
>>>Now I've surfed and surfed and googled my brains out, but cant find out how
>>>to set the field right.
>>>
>>>Can anyone in here enlighten me on this subject.
>>>
>>>Regards,
>>>Henning
>>>
>>>Norway
>>>
> 
> 
0
Reply Michael 6/2/2004 2:37:50 PM

5 Replies
304 Views

(page loaded in 0.066 seconds)

Similiar Articles:













7/26/2012 2:36:00 PM


Reply: