Hi,
I tried a simple addition with python and I don't understand what is
going on:
$python 464.73+279. 78
744.50999999999 999
weird isn't it ? I use python2.3.
comments welcome
Mathieu
Jul 18 '05
11 1678
Rainer Deyke wrote: Dan Bishop wrote:
Why not display the *exact* decimal representation, "0.1000000000 000000055511151 231257827021181 583404541015625 "?
This has my vote. Unfortunately Python seems incapable of figuring out all of those digits.
Python 2.3.2 (#49, Oct 2 2003, 20:02:00) [MSC v.1200 32 bit (Intel)] on win32 Type "help", "copyright" , "credits" or "license" for more information.
'%.64f' % 0.1 '0.100000000000 000010000000000 000000000000000 000000000000000 0000000'
Python 2.3.3 seems to be able to do it on Red Hat Linux 9.0:
[rodh@rodh rodh]$ python
Python 2.3.3 (#1, Dec 20 2003, 17:47:13)
[GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)] on linux2
Type "help", "copyright" , "credits" or "license" for more information. '%.64f' % 0.1
'0.100000000000 000005551115123 125782702118158 340454101562500 0000000'
Must be a M$ MSC problem.
--
Rod
>>>>> "Andrew Koenig" <ar*@acm.org> (AK) wrote:
AK> Many moons ago, Guy Steele proposed an elegant pair of rules for converting
AK> between decimal and internal floating-point, be it binary, decimal,
AK> hexadecimal, or something else entirely:
That was exactly what I was suggesting. I even included the bib reference.
--
Piet van Oostrum <pi**@cs.uu.n l>
URL: http://www.cs.uu.nl/~piet [PGP]
Private email: P.***********@h ccnet.nl This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Gavin Bauer |
last post by:
My DOS window (running in windows ME) closes the second it finishes
running my programs. As you can imagine, this makes it hard to see the
results. I've gotten in the habit of putting raw_input("Press enter to
exit") at the end of every program, and in addition to being pain in
the butt, it often fails to work. Being new to programming in general,
I make more mistakes than most people. My programs often have errors
before they get to my...
|
by: Dales |
last post by:
I have a custom control that builds what we refer to as "Formlets"
around some content in a page. These are basically content "wrapper"
sections that are tables that have a colored header and provide an
open TD with a DIV in it for the content of this formlet. (The DIV is
for DHTML to hide and show the content)
I've created a web page showing step by step the two problems I'm
encountering. This problem is much easier to see than it...
|
by: rdavis7408 |
last post by:
I am attempting what I would think would be a simple calculation of the
cost of traveling a single mile. But I can not figure this out. The
following is my script. Any help would be appreciated.
I want the user to enter the price per gallon in one textbox, the miles
per gallon in the next textbox and then press the button and get the
cost per gallon by dividing the price per gallon by the miles per
gallon.
|
by: Ranginald |
last post by:
Sorry for the simple question but thanks in advance:
My goal is to create reusale code for a web app in C#.
I have written the code already as a windows app but here is where I am
confused:
To keep it really easy let's say this is the code:
function addition(int, int);
int X;
|
by: aum |
last post by:
Hi,
I'm a Python programmer, just starting to get into javascript. On reading
some of the js guides, and not liking any of the OO usage patterns I saw,
I've cooked up something which python folks might find to taste.
Here's the code - first the 'engine', then some code demonstrating the
usage patterns.
For me (and maybe for some of you), it promotes readability and some
| |
by: Mike |
last post by:
Hello All,
Please, if anyone can point me to the problem, I'd sure appreciate it!
I am very new to VB programming and not a programmer to begin with.
This is part of a Visual Basic 2005 Express Edition program to control a remote basketball
scoreboard display unit.
All I'm trying to do is add 5 byte variables and store the result in an integer
variable. I added a Try/Catch block to take look at things.
This exception occurs only when...
|
by: Synapse |
last post by:
Hello...
We were asked to create a simple calculator program in our C++ subject by using loops only. i have a problem in creating a loop in the multiplication and division operation so please can anyone help me on this please. and also during the operation selection, if ill enter a character it wont go back to the main program. by the way, my compiler is Dev-C++.
I need help badly..here's my code below...
#include <iostream.h>
#include...
|
by: wazzup |
last post by:
My task is Create a program to read a simple integer expression and display the result. "Simple" means no parentheses are allowed and only the +, -, *, and / operators are allowed.
I think expression would be Multiplications, then Division, then Addition and Subtraction.
My program gave me a wrong result after addition, take a look to my code you will understand. Please help me to develop this.
Here is my Code
|
by: aagase29 |
last post by:
The code below accepts two numbers from textboxes and should show the addition in the third one.I can t figure out how to display addition in the third text box...
<html>
<body>
<form action="addition_n.asp" method="post">
First number: <input type="text" name="no1" size="20" />
<p>
Second number: <input type="text" name="no2" size="20" value="5" />
</p>
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |