+ Reply to Thread
Results 1 to 18 of 18

Decimal to Whole number

  1. #1
    Registered User
    Join Date
    06-29-2008
    Location
    Boston
    Posts
    7

    Decimal to Whole number

    Hi,

    What is the formula to make say:

    .00045 become the whole number 45

    or any number of decimal places become a whole number, such as:

    .34 = 34

    .023045 = 23045

    .0087 = 87

    etc...


    Thank you in advance for any help on this...

  2. #2
    Forum Contributor
    Join Date
    10-08-2018
    Location
    Lima, Peru
    MS-Off Ver
    Office 365 ProPlus
    Posts
    148

    Re: Decimal to Whole number

    Hi there,

    What about this formula:

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  3. #3
    Forum Expert
    Join Date
    10-15-2018
    Location
    MA, USA
    MS-Off Ver
    2010, 2019
    Posts
    1,616

    Re: Decimal to Whole number

    Another option:

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    10-08-2018
    Location
    Lima, Peru
    MS-Off Ver
    Office 365 ProPlus
    Posts
    148

    Red face Re: Decimal to Whole number

    It doesn't even need to convert number to text:
    Formula: copy to clipboard
    Please Login or Register  to view this content.



  5. #5
    Forum Expert
    Join Date
    05-01-2014
    Location
    California, US
    MS-Off Ver
    Excel 2010
    Posts
    1,795

    Re: Decimal to Whole number

    First, the following formula should suffice:

    =--SUBSTITUTE(A1,".","")

    But second, beware: unless the original numbers were entered as constants, there might be many more digits than you see in the cell.

    For example, =211/9156 appears to be 0.23045 when the cell format is General. But --SUBSTITUTE(A1,".","") results in the number 2304499781564 when formatted as Number with 0 decimal places, because that is the actual value of =211/9156: 0.02304499781564.

  6. #6
    Registered User
    Join Date
    06-29-2008
    Location
    Boston
    Posts
    7

    Re: Decimal to Whole number

    Oh sorry, i should have been more clear:

    I'll have numbers in two different cell like:

    .0023-.0022 = .0001, but I'll want the 3rd cell to do the calculation, then have it show as 1, instead of .0001

    I"m not sure how to plug in something like

    =VALUE(SUBSTITUTE(A2,".","")) or =--SUBSTITUTE(A1,".","") into a cell formula to do both the calculation and come out with the correct number.

    Thank you again for your help guys

  7. #7
    Forum Contributor
    Join Date
    10-08-2018
    Location
    Lima, Peru
    MS-Off Ver
    Office 365 ProPlus
    Posts
    148

    Re: Decimal to Whole number

    =--SUBSTITUTE(B2-A2,".","")
    or
    =VALUE(SUBSTITUTE(B2-A2,".",""))

  8. #8
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Decimal to Whole number

    Try this
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    v A B C
    1 0.0023 0.0022 1
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  9. #9
    Forum Expert
    Join Date
    05-01-2014
    Location
    California, US
    MS-Off Ver
    Excel 2010
    Posts
    1,795

    Re: Decimal to Whole number

    Quote Originally Posted by SarahCohen View Post
    I'll have numbers in two different cell like:
    .0023-.0022 = .0001, but I'll want the 3rd cell to do the calculation, then have it show as 1, instead of .0001
    I"m not sure how to plug in something like
    =VALUE(SUBSTITUTE(A2,".","")) or =--SUBSTITUTE(A1,".","") into a cell formula to do both the calculation and come out with the correct number.
    If you mean that, for example, A1 is 0.0023 and A2 is 0.0022, and you want a formula in A3 that results in the numerical value 1, then following the previous suggestions, we might write the following into A3:

    =--SUBSTITUTE(A1-A2,".","")

    But that is the precisely an example of the problem that I forewarned about.

    The short answer is: if you want the result of A1-A2 to be accurate to 4 decimal places, explicitly round the calculation. So the formula should be:

    =--SUBSTITUTE(ROUND(A1-A2,4),".","")


    On second thought, IMHO, the better solution is:

    =ROUND(A1*10000,0) - ROUND(A2*10000,0)

    The long explanation is....

    The result of the original SUBSTITUTE formula in A3 will be appear to be 10000000000 (!) when A3 is formatted as General.

    And the actual value will be 9999999999.99998, which you can see when A3 is formatted as Number with 5 decimal places.

    The reason, in part, is because 0.0023-0.0022 returns the value 0.0000999999999999998, not 0.0001.

    This is due to well-documented anomalies of binary arithmetic with decimal fractions. In a nutshell, most decimal fractions cannot be represented in the binary form that Excel uses internally, which is called 64-bit binary floating-point.

    So ostensibly, we might expect SUBSTITUTE(A1-A2,".","") to return 00000999999999999998, resulting in the numeric value 999999999999998.

    But in fact, the formula =""&A1-A2 returns the string "9.99999999999998E-05". So SUBSTITUTE(A1-A2,".","") returns the string "999999999999998E-05", which is converted to the numeric value 9999999999.99998 .
    Last edited by joeu2004; 11-04-2018 at 02:46 PM. Reason: second thought; additional explanation

  10. #10
    Forum Contributor
    Join Date
    10-08-2018
    Location
    Lima, Peru
    MS-Off Ver
    Office 365 ProPlus
    Posts
    148

    Re: Decimal to Whole number

    Floating point errors are usually in the 14th and 15th decimal places (with accumulated errors rarely reaching the 13th decimal place). Any rounding to 10 decimal places will be a safe bet.
    This one will work as well, though I guess ROUND is a bit faster than TEXT, in case there were tens of thousands of formulas requiered.

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Leo Skywalker
    May the force be with you.

  11. #11
    Forum Expert
    Join Date
    05-01-2014
    Location
    California, US
    MS-Off Ver
    Excel 2010
    Posts
    1,795

    Re: Decimal to Whole number

    Quote Originally Posted by LeoSkywalker View Post
    Any rounding to 10 decimal places will be a safe bet.
    A1: 34639.969
    A2: 5.273
    A3: =A1-A2
    A4: =ROUND(A3,10) = ROUND(A3,3)

    A4 returns FALSE.

  12. #12
    Forum Expert José Augusto's Avatar
    Join Date
    10-29-2014
    Location
    Portugal
    MS-Off Ver
    2013-2016
    Posts
    3,329

    Re: Decimal to Whole number

    Sorry for the intrusion but I suppose that LeoSkywalker has some reason and only will not have reason to suppose that the values presented in the OP have less than 10 significant digits.

    Like this
    0.11000000001-0.10 = 0.11000000001 => 11000000001

    Rounding each of the parcels or rounding the result to 10 decimal places the result is completely different
    0.1100000000-0.10 = 0.1100000000 => 11

    There is a lack of information so that we can contextualize and formulate a correct response to SarahCohen
    How many decimal places should we work with ?

  13. #13
    Forum Contributor
    Join Date
    10-08-2018
    Location
    Lima, Peru
    MS-Off Ver
    Office 365 ProPlus
    Posts
    148

    Re: Decimal to Whole number

    All of the OP's examples are <1.

    Substracting numbers with several orders of magnitude of difference will effect the needed significant digits:
    1,000,000,000 - 0.0000001 will require more digits than excel can work with, it has only 7 decimal places, though; add this to the floating point calculation error, and of course we'll find failing pairs. As the numbers differences get smaller, the floating point rounding error will move more towards the right.

    Round to 10 places should be compared with round to 9 or 8 places, not 3 places; rounding to 3 or 4 decimal places won't catch pairs like:
    0.00006-0.00004, or 0.00020-0.00015, which are much more likely to occur, as the OP has given numbers like .023045 and 0.00045, and clearly stating in his initial request that "any number of decimal places become a whole number", and all the examples are >0 and <1, so we want to catch the greatest number of decimal places, catching 3 or 4 is reasonable not enough.

    Even 10 decimal places might not be enough, as Jose Augusto points out, Excel has limitations, only 15 digits can be used, trying to play safe, I suggested to remove 5 places due to floating point errors and round to 10 places; rounding to 1,2,3,4, or 5 places will take out many pairs, considering the OP has numbers with 6 decimal places.
    Last edited by LeoSkywalker; 11-05-2018 at 07:38 AM.

  14. #14
    Registered User
    Join Date
    06-29-2008
    Location
    Boston
    Posts
    7

    Re: Decimal to Whole number

    My apologies for the late reply. My computer was in the shop for the longest time. Anyway, long story....

    The answer to your inquiries is that it can have whole numbers also. But no rounding must take place.

    so it can be something like:


    119.34 - 119.45

    or something like: 1.2343 - 1.2365

    etc.

    The numbers I work with will have no more than 4 decimal places.


    So if the subtracted answer becomes negative, I'll need the absolute value of that number (i.e. a positive

  15. #15
    Registered User
    Join Date
    06-29-2008
    Location
    Boston
    Posts
    7

    Re: Decimal to Whole number

    Quote Originally Posted by AlKey View Post
    Try this
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Hi AlKey,

    Your formula worked for the example above, but if I have a number such as:

    119.7700 - 119.6800, it gives the result as 0.09, instead of 9. Is there a way to make the resulting answer to be 9 also in this type of situation?
    Last edited by jeffreybrown; 11-12-2018 at 01:50 PM.

  16. #16
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Decimal to Whole number

    Responding to post #15:

    =MID(A1,FIND(".",A1)+1,15)-MID(B1,FIND(".",B1)+1,15)

  17. #17
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: Decimal to Whole number

    SarahCohen,

    Why not post a workbook with many examples of what you have and what you expect.

    Attach a sample workbook (not a picture or pasted copy). Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    HTH
    Regards, Jeff

  18. #18
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Decimal to Whole number

    Here is another one
    Formula: copy to clipboard
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Find largest decimal number based on selected whole number
    By primed in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-07-2018, 08:22 AM
  2. Want to separate number and decimal. After need to sum of number & decimal.
    By kumarp11 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-03-2014, 02:11 PM
  3. [SOLVED] copy number with 3 or more decimal places and paste the actual value as 2 decimal number
    By k1dr0ck in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-29-2013, 12:57 AM
  4. Replies: 2
    Last Post: 06-29-2012, 07:52 PM
  5. Paste two decimal number in excel without extra decimal places appearing
    By jeffery_frick in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-13-2009, 07:49 PM
  6. Replies: 3
    Last Post: 03-18-2006, 02:25 PM
  7. How to convert a decimal number to a non-decimal number?
    By snickers22 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-13-2005, 07:06 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1