Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 150
Default Excel precision issues with float/single

If I have a float variable with a value of 9.9 (as seen in the debugger), and
I set it to an Excel cell, the cell value is 9.89999961853027. However, if I
have a double variable with the same value of 9.9, setting that to an Excel
cell gives me the correct value.

(Note that the cell, in it's default size, looks correct, but if you expand
the cell, or click on the value and look on the editor area, the value is
incorrect.)

Am I doing something wrong? How do I fix this? Thanks much!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Excel precision issues with float/single

Cells hold all numbers as double, so when when the number is converted from
single to double, it takes on the imprecision. I suspect this has to do with
how floating point numbers are stored.

--
Regards,
Tom Ogilvy


"Julie" wrote:

If I have a float variable with a value of 9.9 (as seen in the debugger), and
I set it to an Excel cell, the cell value is 9.89999961853027. However, if I
have a double variable with the same value of 9.9, setting that to an Excel
cell gives me the correct value.

(Note that the cell, in it's default size, looks correct, but if you expand
the cell, or click on the value and look on the editor area, the value is
incorrect.)

Am I doing something wrong? How do I fix this? Thanks much!

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
ieee754 single precision numbers staff Excel Discussion (Misc queries) 2 May 31st 07 03:07 PM
How to make a key float in an excel wksh when a person scrolls. Kelly Excel Worksheet Functions 5 March 7th 07 06:23 PM
Precision in Excel 2002 James Silverton Charts and Charting in Excel 2 August 14th 06 06:33 PM
Loss of caluclating precision (VBA vs Excel) Alex Excel Discussion (Misc queries) 1 October 13th 05 03:13 PM
Precision displayed does not match precision in cell James Wilkerson Excel Discussion (Misc queries) 10 June 15th 05 02:40 PM


All times are GMT +1. The time now is 05:36 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"