Hi,
Considering the float 0.0, I would like to print 00.00.
I tried '%02.02f' % 0.0 ... but I get 0.00
Any clue ?
Thanks,
hg 11 2788
hg skrev:
Hi,
Considering the float 0.0, I would like to print 00.00.
I tried '%02.02f' % 0.0 ... but I get 0.00
Any clue ?
Thanks,
hg
Try this:
a = 45.45 # the floating number
print "some text",
print a,
print "some text again"
or just this:
print "some text",
print 45.45,
print "some text again"
Hope it helped :D
Andreas
On 2007-02-13, hg <hg@nospam.orgwrote:
Hi,
Considering the float 0.0, I would like to print 00.00.
I tried '%02.02f' % 0.0 ... but I get 0.00
Any clue ?
Yes. How wide (total) is "0.00", compared to "00.00"?
--
Neil Cerutti
Neil Cerutti wrote:
On 2007-02-13, hg <hg@nospam.orgwrote:
>Hi,
Considering the float 0.0, I would like to print 00.00.
I tried '%02.02f' % 0.0 ... but I get 0.00
Any clue ?
Yes. How wide (total) is "0.00", compared to "00.00"?
--
Neil Cerutti
I do not get it
s = '%02.02f' % 0.0
s
>'0.00'
len(s)
>4
NOSPAM plz wrote:
hg skrev:
>Hi,
Considering the float 0.0, I would like to print 00.00.
I tried '%02.02f' % 0.0 ... but I get 0.00
Any clue ?
Thanks,
hg
Try this:
a = 45.45 # the floating number
print "some text",
print a,
print "some text again"
or just this:
print "some text",
print 45.45,
print "some text again"
Hope it helped :D
Andreas
Sorry,
must be very slow or not enough coffee yet ... my purpose is to display a
justified report, so I format my floats into strings which I next draw in a
bitmap.
hg
hg wrote:
Considering the float 0.0, I would like to print 00.00.
I tried '%02.02f' % 0.0 ... but I get 0.00
Any clue ?
The first integer specifies the total width:
>>"%05.2f" % 0
'00.00'
Peter
Peter Otten wrote:
hg wrote:
>Considering the float 0.0, I would like to print 00.00.
I tried '%02.02f' % 0.0 ... but I get 0.00
Any clue ?
The first integer specifies the total width:
>>>"%05.2f" % 0
'00.00'
Peter
Many thanks !
hg
On 2007-02-13, hg <hg@nospam.orgwrote:
Neil Cerutti wrote:
>On 2007-02-13, hg <hg@nospam.orgwrote:
>>Hi,
Considering the float 0.0, I would like to print 00.00.
I tried '%02.02f' % 0.0 ... but I get 0.00
Any clue ?
Yes. How wide (total) is "0.00", compared to "00.00"?
-- Neil Cerutti
I do not get it
s = '%02.02f' % 0.0
The first number after the percent is the minimum width specifier
for the ENTIRE field.
s
>>'0.00'
len(s)
>>4
It is the MINIMUM width specifier for the entire field.
--
Neil Cerutti
The eighth-graders will be presenting Shakespeare's Hamlet in the church
basement on Friday at 7 p.m. The congregation is invited to attend this
tragedy. --Church Bulletin Blooper
Neil Cerutti wrote:
The eighth-graders will be presenting Shakespeare's Hamlet in the church
basement on Friday at 7 p.m. The congregation is invited to attend this
tragedy. --Church Bulletin Blooper
;-) I like that !
hg
On 2007-02-13, hg <hg@nospam.orgwrote:
Hi,
Considering the float 0.0, I would like to print 00.00.
I tried '%02.02f' % 0.0 ... but I get 0.00
^^
That's the specifierfor how many total columns you want to use
(including the decimal point and all digits to either side).
Any clue ?
>>"%05.02f" % 0.0
'00.00'
--
Grant Edwards grante Yow! Yow!! "Janitor
at trapped in sewer uses ESP
visi.com to find decayed burger"!!
On 2007-02-13, hg <hg@nospam.orgwrote:
NOSPAM plz wrote:
>>Considering the float 0.0, I would like to print 00.00.
I tried '%02.02f' % 0.0 ... but I get 0.00
>Try this:
a = 45.45 # the floating number
print "some text", print a, print "some text again"
Sorry,
must be very slow or not enough coffee yet...
Don't worry. I do know what you did wrong and how to fix it,
and I have absolutely no idea what "NOSPAM plz" is trying to
say either.
--
Grant Edwards grante Yow! I'm in a twist
at contest!! I'm in a
visi.com bathtub! It's on Mars!! I'm
in tip-top condition!
Grant Edwards wrote:
On 2007-02-13, hg <hg@nospam.orgwrote:
>Hi,
Considering the float 0.0, I would like to print 00.00.
I tried '%02.02f' % 0.0 ... but I get 0.00
^^
That's the specifierfor how many total columns you want to use
(including the decimal point and all digits to either side).
>Any clue ?
>>>"%05.02f" % 0.0
'00.00'
--
Grant Edwards grante Yow! Yow!! "Janitor
at trapped in sewer uses
ESP
visi.com to find decayed
burger"!!
Thanks This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Bernard Delmée |
last post by:
Is there a simple way to modify the default sprintf mask
used for floats ? (eg something like sys.float_mask = '%.2f')
I've tried assigning to float.__dict__, but
that's apparently not allowed.
|
by: David Sharp |
last post by:
I'm trying to find a way to format a FLOAT variable into a varchar in
SQL Server 2000 but using CAST/CONVERT I can only get scientific
notation i.e. 1e+006 instead of 1000000 which isn't really...
|
by: hpy_awad |
last post by:
formatting float variables to fprintf has error to my writing to
output file called rental and I do not the reason that a rabish is
written to the file instead of the actual input screen values ?
...
|
by: Brian |
last post by:
Hello all,
I am a bit stuck with a float formatting issue. What I want to do is
print a float to the screen with each line showing one more decimal
place. Here is a code snip that may explain...
|
by: Juergen |
last post by:
hi,
I've got a problem sending floating point values to an corba server.
With other datatyes like short or string it works fine.
So having this idl file :
module Example{
interface User{
| |
by: ashkaan57 |
last post by:
Hi,
I am trying to put text on left and right side of the page and used:
<div>
<span>blah blah</span>
<span style="float:right">blah blah</span>
</div>
The 2nd text does go to the right but the...
|
by: mathieu |
last post by:
Hi,
I know I am doing something stupid here, but it's friday night and I
cannot see what is the issue here:
Thanks,
-Mathieu
#include <iostream>
|
by: helen.m.flynn |
last post by:
Hi I'm very much a beginner with Python.
I want to write a function to convert celcius to fahrenheit like this
one:
def celciusToFahrenheit(tc):
tf = (9/5)*tc+32
return tf
I want the answer...
|
by: Selvam |
last post by:
Hi All,
I am getting exponent value when doing float arithmetic in C++.
Instead of that I need accurate value.
float amount = 0.0f;
float x = 0.99999976f;
amount= 1.0f - x;
I am getting...
|
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,...
|
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...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
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...
|
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...
|
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,...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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 ...
| |