4.2.1 is rounding integers

Discussion of the version of HanDBase that runs on the iPhone and iPod touch devices. This includes the synchronization conduits as well.

4.2.1 is rounding integers

Postby Russ » Tue Jul 14, 2009 10:53 pm

HanDBase 4.2.1 on my iPod Touch is rounding integers rater than dropping the value after the decimal. A calculated value of 1.5 ends up being rounded up to 2 rather than the .5 being dropped.

Thanks
Russ
Russ
 
Posts: 4
Joined: Wed Jul 08, 2009 6:06 pm

Re: 4.2.1 is rounding integers

Postby dhaupert » Wed Jul 15, 2009 10:08 am

Russ wrote:HanDBase 4.2.1 on my iPod Touch is rounding integers rater than dropping the value after the decimal. A calculated value of 1.5 ends up being rounded up to 2 rather than the .5 being dropped.

Thanks
Russ


Hi Russ,

If you'd like to have an unrounded integer result in a calculation, you'll want to use the 'floor' function around your calculation. For example, if you have two float fields being added together like this:

Field 1: Float
Field 2: Float
Field 3: Calc with formula F1+F2

and you enter 1.0 and 0.5, you'll get 2.0 as the rounded value.

But if you change Field 3's formula to be: Floor(F1+F2)
it will drop off any decimal point in the result. Hope this helps!
dhaupert
 
Posts: 4111
Joined: Tue May 26, 2009 11:51 am

Re: 4.2.1 is rounding integers

Postby Russ » Wed Jul 15, 2009 11:18 am

Thanks Dave, Is that new? The database that I encountered this on is actually one that I built several years ago on my Palm and it worked fine (not rounding integers) then. I thought that it also used to work (as I had expected) when I first migrated to iPod Touch. It has been about a year since I used this database and now it does the rounding thing. I'm not trying to gripe, just confused. I will use the floor function and I appreciate your reply.

Thank you
Russ
Russ
 
Posts: 4
Joined: Wed Jul 08, 2009 6:06 pm

Re: 4.2.1 is rounding integers

Postby dhaupert » Thu Jul 16, 2009 10:22 am

Russ wrote:Thanks Dave, Is that new? The database that I encountered this on is actually one that I built several years ago on my Palm and it worked fine (not rounding integers) then. I thought that it also used to work (as I had expected) when I first migrated to iPod Touch. It has been about a year since I used this database and now it does the rounding thing. I'm not trying to gripe, just confused. I will use the floor function and I appreciate your reply.

Thank you
Russ


It's not that HanDBase has ever rounded or not rounded on other platforms as much as we use a system call to convert a floating point value to an integer value. In the case of the iPhone I'm not sure it's always rounding- as 2.5 seems to go to 2.0. I'd say that the decimal point seems undefined. I'm going to check that there isn't a bug there, but at least for now you have a suitable workaround!
dhaupert
 
Posts: 4111
Joined: Tue May 26, 2009 11:51 am


Return to HanDBase for iPhone and iPod touch

Who is online

Users browsing this forum: Bing [Bot] and 1 guest