Re: strings (dollar.cents) into floats



On Sep 1, 4:51 am, Dennis Lee Bieber <wlfr...@xxxxxxxxxxxxx> wrote:
On Fri, 31 Aug 2007 12:06:49 -0400, Steve Holden <st...@xxxxxxxxxxxxx>
declaimed the following in comp.lang.python:

That last sentence is patent nonsense, and completely untrue. Many
satisfactory financial applications have been written using only
floating-point arithmetic. Indeed I believe the accountant's Swiss army
knife, the Excel spreadsheet, uses floating-point numbers exclusively.

Excel supports M$'s "Currency" data type

That sentence is also completely untrue. Excel supports only IEEE 754
64-bit floating point, and that is how bean-counts, temperature
readings, dates, and money amounts are stored in an XLS file. What is
confusing you may be the "helpful" way that COM etc examine the
"number format" that's been used on a cell.

Example: actual value is 1.234567..... (a float). The "number format"
used in Excel causes it to be displayed as $1.23. However what COM etc
produce when they extract the data is a "currency" or "money" instance
containing $1.2345 which is NEITHER what you see NOR what you've
actually got. That's a somewhat Procrustean attitude to "support".

-- which I believe is a
64-bit INTEGER scaled for four decimal places.

It's "general" format is a variant type accepting integer, float,
text, date/time (but can't differentiate currency form float on input)

Excel has no concept of a variant type. "General" is a "number
format", not a data type. Excel has storage types corresponding to
Python's float, unicode (16 bit), bool and None, as well as an error
type.


.



Relevant Pages

  • Re: Modular Arithmetic
    ... is most popular in programming languages. ... floating-point arithmetic; ... precision, that gets rounded to 1e200 (assuming a sane rounding mode is in ... For example, try that in Excel. ...
    (sci.math)
  • Re: It doesnt add up - Its driving me crazy
    ... says rounding and precision in Excel. ... Floating-Point Arithmetic May Give Inaccurate Results ... Rounding Errors In Visual Basic For Applications ... "Francis Hayes (The Excel Addict)" ...
    (microsoft.public.excel.programming)
  • Re: What is contained in excel intermediate?
    ... Floating-point arithmetic may give inaccurate results in Excel ... Bernard V Liengme ...
    (microsoft.public.excel.misc)
  • Re: What is contained in excel intermediate?
    ... "Bernard Liengme" wrote: ... Floating-point arithmetic may give inaccurate results in Excel ... copy of excel for dummies should be with me on Tuesday!! ...
    (microsoft.public.excel.misc)
  • RE: Excel & MS Query caused compile errors
    ... My data is in an Excel file called ... The format of it were distorted after copying and pasting. ... Microsoft SQL Server 2000, which requires a server, VBA or Microsoft Query ...
    (microsoft.public.excel.programming)