Re: Float to String

2012-10-31 Thread Mark Dickinson
od, dtoa and sprintf functions) to do float-to-string and string-to-float conversions, and hence behaves differently from platform to platform. In particular, it's common for near halfway cases (like the one you're looking at here) and tiny numbers to give different results on different platfor

Re: Float to String "%.7e" - diff between Python-2.6 and Python-2.7

2012-10-30 Thread Dave Angel
On 10/30/2012 10:47 AM, andrew.macke...@3ds.com wrote: > When formatting a float using the exponential format, the rounding is > different in Python-2.6 and Python-2.7. See example below. > Is this intentional? > > Is there any way of forcing the Python-2.6 behavior (for compatibility > reasons w

Re: Float to String "%.7e" - diff between Python-2.6 and Python-2.7

2012-10-30 Thread Duncan Booth
andrew.macke...@3ds.com wrote: > When formatting a float using the exponential format, the rounding is > different in Python-2.6 and Python-2.7. See example below. Is this > intentional? > > Is there any way of forcing the Python-2.6 behavior (for compatibility > reasons when testing)? > It is

Float to String "%.7e" - diff between Python-2.6 and Python-2.7

2012-10-30 Thread andrew . mackeith
When formatting a float using the exponential format, the rounding is different in Python-2.6 and Python-2.7. See example below. Is this intentional? Is there any way of forcing the Python-2.6 behavior (for compatibility reasons when testing)? >c:\python26\python r:\asiData\abaObjects\lib>c:\py

Re: float to string with different precision

2007-08-10 Thread Roger Miller
On Aug 10, 8:37 am, Zentrader <[EMAIL PROTECTED]> wrote: > > If the above does not work > [/code]test_list = [ 5.32, 10.35634, 289.234 ] > for num in test_list : >str_num = "%11.5f" % (num) ## expand to at least 5 >print str_num, "-->", str_num.strip()[:5][/code] This has the disadva

Re: float to string with different precision

2007-08-10 Thread Zentrader
On Aug 10, 1:12 am, Peter Otten <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > I have to print float numbers to a file. Each float should be 5 > > characters in width (4 numbers and the decimal point). > > My problem is that I do not now how to specify float to have different > > number

Re: float to string with different precision

2007-08-10 Thread Peter Otten
[EMAIL PROTECTED] wrote: > I have to print float numbers to a file. Each float should be 5 > characters in width (4 numbers and the decimal point). > My problem is that I do not now how to specify float to have different > numbers of decimals. For example > > 5.32 -> 5.320 > 10.356634 -> 10.357

float to string with different precision

2007-08-10 Thread zunbeltz
Hi, I have to print float numbers to a file. Each float should be 5 characters in width (4 numbers and the decimal point). My problem is that I do not now how to specify float to have different numbers of decimals. For example 5.32 -> 5.320 10.356634 -> 10.357 289.234 -> 289.2 In the string form

Re: Convert float to string ...

2005-08-23 Thread Matt Hammond
> How can i convert a float value into a string value? Try: string_value1 = str(float_value) + ' abc' or: string_value1 = repr(float_value) + ' abc' Type in an interactive python session. help(str) or: help(repr) regards Matt -- | Matt Hammond | R&D Engineer, BBC Resear

Re: Convert float to string ...

2005-08-23 Thread Fredrik Lundh
Konrad Mühler wrote: > a simple question but i found no solution: > > How can i convert a float value into a string value? > > > string_value1 = string(float_value) + ' abc' str(float_value) + 'abc' repr(float_value) + "abc" '%fabc' % float_value '%gabc' % float_value (etc) the tutorial has

Re: Convert float to string ...

2005-08-23 Thread deelan
Konrad Mühler wrote: > Hi, > > a simple question but i found no solution: > > How can i convert a float value into a string value? > just use the "str" built-in type: >>> f = 9.99 >>> str(f) '9.99' -- deelan, #1 fan of adriana lima! -- http://mail.python.org/mail

Re: Convert float to string ...

2005-08-23 Thread Grant Edwards
On 2005-08-23, Konrad Mühler <[EMAIL PROTECTED]> wrote: > Hi, > > a simple question but i found no solution: > > How can i convert a float value into a string value? > > > string_value1 = string(float_value) + ' abc' string_value1 = str(float_value) + ' abc' Or the more versatile: string_value

Re: Convert float to string ...

2005-08-23 Thread Simon Brunning
On 8/23/05, Konrad Mühler <[EMAIL PROTECTED]> wrote: > How can i convert a float value into a string value? > > string_value1 = string(float_value) + ' abc' string_value1 = str(float_value) + ' abc' -- Cheers, Simon B, [EMAIL PROTECTED], http://www.brunningonline.net/simon/blog/ -- http://mail

Convert float to string ...

2005-08-23 Thread Konrad Mühler
Hi, a simple question but i found no solution: How can i convert a float value into a string value? string_value1 = string(float_value) + ' abc' doesn't work ... Thanks Konrad -- http://mail.python.org/mailman/listinfo/python-list