Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #112084

Re: Float

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Dennis Lee Bieber <wlfraed@ix.netcom.com>
Newsgroups comp.lang.python
Subject Re: Float
Date Sat, 30 Jul 2016 12:03:02 -0400
Organization IISS Elusive Unicorn
Lines 31
Message-ID <mailman.54.1469895489.6033.python-list@python.org> (permalink)
References <da5a1bae-813f-4fef-a7b6-f67f258bcc85@googlegroups.com> <579b67b0$0$1614$c3e8da3$5496439d@news.astraweb.com> <367666cb-224f-4b16-88bb-cd1ada13a13b@googlegroups.com> <579c82a6$0$1619$c3e8da3$5496439d@news.astraweb.com> <e5d77dc3-2fe4-4352-9582-8a259f3c4f9d@googlegroups.com> <CAPTjJmri1uAicp_VnZ+b3+goWASGkW4yaAKJdLqcbs2N72Sz_Q@mail.gmail.com> <apjppbtocn2vs6v581clq8470on5b14sce@4ax.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 <python-python-list@m.gmane.org>
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 <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID <apjppbtocn2vs6v581clq8470on5b14sce@4ax.com>
X-Mailman-Original-References <da5a1bae-813f-4fef-a7b6-f67f258bcc85@googlegroups.com> <579b67b0$0$1614$c3e8da3$5496439d@news.astraweb.com> <367666cb-224f-4b16-88bb-cd1ada13a13b@googlegroups.com> <579c82a6$0$1619$c3e8da3$5496439d@news.astraweb.com> <e5d77dc3-2fe4-4352-9582-8a259f3c4f9d@googlegroups.com> <CAPTjJmri1uAicp_VnZ+b3+goWASGkW4yaAKJdLqcbs2N72Sz_Q@mail.gmail.com>
Xref csiph.com comp.lang.python:112084

Show key headers only | View raw


On Sat, 30 Jul 2016 21:51:29 +1000, Chris Angelico <rosuav@gmail.com>
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/

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Float Cai Gengyang <gengyangcai@gmail.com> - 2016-07-29 02:44 -0700
  Re: Float Lutz Horn <lutz.horn@posteo.de> - 2016-07-29 11:56 +0200
  Re: Float Ben Finney <ben+python@benfinney.id.au> - 2016-07-29 20:25 +1000
  Re: Float Steven D'Aprano <steve@pearwood.info> - 2016-07-30 00:26 +1000
    Re: Float Cai Gengyang <gengyangcai@gmail.com> - 2016-07-30 03:21 -0700
      Re: Float Steven D'Aprano <steve@pearwood.info> - 2016-07-30 20:34 +1000
        Re: Float Cai Gengyang <gengyangcai@gmail.com> - 2016-07-30 04:44 -0700
          Re: Float Chris Angelico <rosuav@gmail.com> - 2016-07-30 21:51 +1000
            Re: Float Rustom Mody <rustompmody@gmail.com> - 2016-07-30 20:20 -0700
              Re: Float Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-08-04 00:28 -0700
          Re: Float Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-07-30 12:03 -0400
          Re: Float eryk sun <eryksun@gmail.com> - 2016-07-30 18:19 +0000

csiph-web