Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Dennis Lee Bieber Newsgroups: comp.lang.python Subject: Re: Float Date: Sat, 30 Jul 2016 12:03:02 -0400 Organization: IISS Elusive Unicorn Lines: 31 Message-ID: References: <579b67b0$0$1614$c3e8da3$5496439d@news.astraweb.com> <367666cb-224f-4b16-88bb-cd1ada13a13b@googlegroups.com> <579c82a6$0$1619$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de izjq+IShZKc0Od9ZNKPDcwJNJ0Xo8uGpoGUcCBP/Sr/A== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; '*is*': 0.09; 'message- id:@4ax.com': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'underlying': 0.09; '2016': 0.16; '3.0)': 0.16; '>in': 0.16; '>they': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'route,': 0.16; 'integer': 0.18; 'url:home': 0.18; '>>>': 0.20; 'struct': 0.22; 'sat,': 0.23; 'import': 0.24; 'header:X -Complaints-To:1': 0.26; 'chris': 0.26; '3.0': 0.27; 'context,': 0.29; 'waste': 0.30; 'computing': 0.32; 'int': 0.33; 'equal': 0.34; 'but': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'charset:us-ascii': 0.37; 'represent': 0.38; 'data': 0.39; 'rather': 0.39; 'to:addr:python.org': 0.40; 'float:': 0.72; 'jul': 0.72; 'incredibly': 0.76; '+1000,': 0.84; 'dennis': 0.91 X-Injected-Via-Gmane: http://gmane.org/ X-Newsreader: Forte Agent 6.00/32.1186 X-No-Archive: YES X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: <579b67b0$0$1614$c3e8da3$5496439d@news.astraweb.com> <367666cb-224f-4b16-88bb-cd1ada13a13b@googlegroups.com> <579c82a6$0$1619$c3e8da3$5496439d@news.astraweb.com> Xref: csiph.com comp.lang.python:112084 On Sat, 30 Jul 2016 21:51:29 +1000, Chris Angelico declaimed the following: >In a computing context, data types are incredibly significant. So yes, >3.0 *is* a floating-point number. It's equal to the integer 3, because >they represent the same number, but it's not identical to it. You can >convert from one to the other with the built-ins int and float: > >>>> 3.0 == 3 >True >>>> int(3.0) >3 >>>> float(3) >3.0 And in a rather convoluted route, one can get to the underlying representation... >>> import struct >>> f = struct.pack(">f", 3.0) >>> i = struct.pack(">i", 3) >>> fi = struct.unpack(">i", f) >>> ii = struct.unpack(">i", i) #really a waste of time >>> "0x%8.8X 0x%8.8X" % (fi[0], ii[0]) '0x40400000 0x00000003' >>> -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/