My Assistant
Custom Search

Is Single Number Divisible By 2, Any Version 
Feb 12 2019, 03:42 AM Post#1  
Posts: 1,066 Joined: 16June 05  I need to determine if a number (format single) is exactly divisible by 2 e.g 13.78 is (6.89) 13.79 is not (8.895) How do I determine this with code? Thanks in advance 
Feb 12 2019, 03:52 AM Post#2  
Posts: 60 Joined: 18August 16 From: Bristol, UK  IF x/2=INT(x/2) THEN ...... Where x is your number. 
Feb 12 2019, 04:30 AM Post#3  
UtterAccess VIP Posts: 11,022 Joined: 6December 03 From: Telegraph Hill  What do you mean 'exactly divisible by 2'? To me, that means that the result is a whole number, but your examples show something different: 13.78 is (6.89) < this is exactly divisible by 2 ?? 13.79 is not (8.895) < should this not be 6.895 ?? d  Regards, David Marten 
Feb 12 2019, 04:39 AM Post#4  
Posts: 1,066 Joined: 16June 05  Thanks Vince This post has been edited by TimTDP: Feb 12 2019, 04:40 AM 
Feb 12 2019, 04:58 AM Post#5  
Posts: 1,066 Joined: 16June 05  13.78 is (6.89) < this is exactly divisible by 2 ?? 13.79 is not (8.895) < should this not be 6.895 ?? So I guess I am looking for a return of no more than 2 decimal points I need this for an account purpose So I have 2 persons responsible for an account If the account value = 13.78, then both parties pay 6.89 13.79, then one party pays 6.90 & the other 6.89 
Feb 12 2019, 05:31 AM Post#6  
UtterAccess VIP Posts: 11,022 Joined: 6December 03 From: Telegraph Hill  OK, CODE If ((x / 2) * 100) MOD 2 = 0 Then ' Divisible by 2 Else ' More than 2 dp End If Consider using Currency datatype instead of Single for working with monetary values  it's less prone to rounding errors. hth, d  Regards, David Marten 
Custom Search

Search Top LoFi  23rd April 2019  05:08 AM 