Results 1 to 8 of 8
  1. #1
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    513

    4 * 2.4 = 190000038146973 ( !!! ? )

    this is BASIC ACCESS 101 (I feel stupid even asking); but, i am.
    maybe this issue has always been and i never noticed (seriously ?!)
    but i'm noticing it now

    2 fields:
    QTY -> number, long integer, decimal = auto,
    INPUT_LOAD -> number, single, decimal = auto


    ...i have no idea why one is a 'long integer' and the other 'single' (could be a legacy thing when M$oft changed their field types a few years back?)
    both will store a number less than 100,000 and both could have up to 2 decimal places (....maybe not INPUT LOAD. it may, by coincidence, always be an integer ...or when it should be a decimal, and it rounds, no one has cared enough to comment ?!)


    both in VBA code and as a calculated control value in a report, the same weirdness occurs.
    anytime INPUT LOAD has a decimal and i multiply (
    QTY * INPUT_LOAD), the calculated result is something consistently like this:

    4 * 2.4 = 190000038146973 ( !!! ? )

    Field Data type issues I'm certain. Yes ?



    as always,
    with appreciation in advance,
    m.

  2. #2
    jojowhite's Avatar
    jojowhite is offline Competent Performer
    Windows 11 Access 2021
    Join Date
    Jan 2025
    Posts
    438
    it is certainly a bug.
    you should tell (feedback) microsoft about it.
    Click image for larger version. 

Name:	feed_back.png 
Views:	24 
Size:	67.5 KB 
ID:	52781

    meantime, will converting both field to Dec in your calculation
    solve this:
    Code:
    CDec([QTY]) * CDec([INPUT_LOAD])

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Testing in Access 2020.

    In VBA and query, result is 9.60000038146973.

    So something weird in 365.

    I don't think field types were actually changed. In Access 2016 LargeNumber (BigInt) and Date/TimeExtended were added and Memo and Text were renamed to LongText and ShortText.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    Gustav's Avatar
    Gustav is offline Advanced Beginner
    Windows 11 Office 365
    Join Date
    Jan 2025
    Posts
    32
    It certainly is not a bug, only demonstating the limitation of data type Single, which only should be used in very special cases.
    Always use Currency for amounts, quantities, and similar, though - in this case - even Double will do:
    Code:
    ? CLng(4) * CSng(2.4 )
     9.60000038146973 
     
    ? CCur(4) * CCur(2.4 )
     9.6 
    
    
    ? CLng(4) * CDbl(2.4 )
     9.6

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Gustav, OP says result they get is 190000038146973

    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    Edgar is offline Competent Performer
    Windows 8 Access 2016
    Join Date
    Dec 2022
    Posts
    309
    Can't reproduce that number. I get what the others get: an approximation, which is a result of dealing with Single data type. Do not use that data type if you need precision, that data type is used when you're dealing with stuff from which you don't really need accurate measurements. Simulations, visuals, 3d rendering, animation, experiments, quick calculations, etc. Cast to double, which is what VBA will do anyway with the result.
    Please click on the ⭐ below if this post helped you.


  7. #7
    Gustav's Avatar
    Gustav is offline Advanced Beginner
    Windows 11 Office 365
    Join Date
    Jan 2025
    Posts
    32
    Sorry, missed that.
    Can't replicate that integer number. Something else is probably going on.

  8. #8
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,823
    I get the same as Gustav.
    Can you upload a copy of the database?

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Help With Runtime Error 4248
    By KLahvic in forum Programming
    Replies: 1
    Last Post: 04-09-2010, 07:47 AM
  2. Replies: 3
    Last Post: 01-15-2010, 02:28 PM
  3. Replies: 5
    Last Post: 08-05-2009, 04:07 PM
  4. Importing Time Data from AS/400
    By smunie in forum Import/Export Data
    Replies: 0
    Last Post: 11-17-2006, 03:12 PM
  5. Run Time Error 424
    By ddog171 in forum Programming
    Replies: 3
    Last Post: 02-04-2006, 07:13 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums