View Poll Results: Will using an integer for cash like above work?

Voters
2. You may not vote on this poll
  • Yes

    1 50.00%
  • No

    1 50.00%
Results 1 to 4 of 4

Thread: Integer with Decimals

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2002
    Posts
    40

    Integer with Decimals

    Ok, so here's my thought I am developing a program that has small cash values (should never be more than a few thousand. I am thinking of using an integer value /1000 as the data type (I need to round off correctly and am interested in the tenth of a cent. Any thoughts?

  2. #2
    Fanatic Member rudvs2's Avatar
    Join Date
    Mar 2001
    Location
    NZ
    Posts
    935
    I would still use the decimal data type. This data type is designed for handeling floating point numbers where as integer divided by 1000 is not. You may get rounding problems using the integer method.

  3. #3

    Thread Starter
    Member
    Join Date
    Sep 2002
    Posts
    40

    hmmmm

    I'm not really concerned with anything beyond a tenth of a cent for rounding purposes. Any other reasons why I shouldn't use integer/1000.

  4. #4
    New Member
    Join Date
    Oct 2002
    Location
    Saudi Arabia
    Posts
    8
    I would suggest you do not attempt "to save the byte" by using an integer to represent a floating point number. Think about code maintenance and all unforeseen problems in the future. What are the gains? Few megs saved? Few disk i/o's? Hardware prices are way lower than the price of laborious coding.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width