CARVIEW |
Select Language
HTTP/2 302
server: nginx
date: Thu, 17 Jul 2025 07:43:37 GMT
content-type: text/plain; charset=utf-8
content-length: 0
x-archive-redirect-reason: found capture at 20071208115246
location: https://web.archive.org/web/20071208115246/https://wiki.python.org/moin/SubtractionQuestion
server-timing: captures_list;dur=0.691261, exclusion.robots;dur=0.024017, exclusion.robots.policy;dur=0.012219, esindex;dur=0.016272, cdx.remote;dur=129.078675, LoadShardBlock;dur=272.253292, PetaboxLoader3.datanode;dur=92.861529, PetaboxLoader3.resolve;dur=116.912400
x-app-server: wwwb-app221
x-ts: 302
x-tr: 431
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=1
set-cookie: SERVER=wwwb-app221; path=/
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
HTTP/2 200
server: nginx
date: Thu, 17 Jul 2025 07:43:38 GMT
content-type: text/html;charset=utf-8
x-archive-orig-date: Sat, 08 Dec 2007 11:52:46 GMT
x-archive-orig-server: Apache/2.0.54 (Debian GNU/Linux) mod_fastcgi/2.4.2
x-archive-orig-connection: close
x-archive-guessed-content-type: text/html
x-archive-guessed-charset: utf-8
memento-datetime: Sat, 08 Dec 2007 11:52:46 GMT
link: ; rel="original", ; rel="timemap"; type="application/link-format", ; rel="timegate", ; rel="first memento"; datetime="Tue, 16 May 2006 08:47:10 GMT", ; rel="prev memento"; datetime="Sat, 11 Aug 2007 11:00:06 GMT", ; rel="memento"; datetime="Sat, 08 Dec 2007 11:52:46 GMT", ; rel="last memento"; datetime="Sat, 08 Dec 2007 11:52:46 GMT"
content-security-policy: default-src 'self' 'unsafe-eval' 'unsafe-inline' data: blob: archive.org web.archive.org web-static.archive.org wayback-api.archive.org athena.archive.org analytics.archive.org pragma.archivelab.org wwwb-events.archive.org
x-archive-src: 52_1_20071208104348_crawl102-c/52_1_20071208115139_crawl107.arc.gz
server-timing: captures_list;dur=0.823360, exclusion.robots;dur=0.020117, exclusion.robots.policy;dur=0.008909, esindex;dur=0.014469, cdx.remote;dur=49.729254, LoadShardBlock;dur=311.012844, PetaboxLoader3.datanode;dur=135.285299, PetaboxLoader3.resolve;dur=233.827664, load_resource;dur=134.008102
x-app-server: wwwb-app221
x-ts: 200
x-tr: 548
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
content-encoding: gzip
SubtractionQuestion - PythonInfo Wiki
SubtractionQuestion
I discovered this when my students were creating a fraction class. 7/4 = 1 however -7/4 = -2 It seems to me the second result should be -1 It appears it is using the floor function but it isn't what my students wanted nor can I think of when anyone would want this result. Anyone know why? Thanks for any help Terry S - tscott@fisher.unco.edu
That is what floor division does, it reduces the value to the next lowest whole number. If you want to separate the whole number and fractional part, use math.modf:
from __future__ import division import math print math.modf(25/12) --> (0.08333, 2.0) print math.modf(-25/12) --> (-0.08333, -2.0) #to just print the whole number as an int: print int(math.modf(25/12)[1])
Please see the Python Programming FAQ, question 1.3.2, for an explanation.
EditText (last edited 2005-01-09 16:52:43 by DougHolton)
DeleteCache (cached 2007-12-03 01:38:13)- Login
- Navigation
- Actions
- Your recent pages