float

converting float to int: rounding in complex cases (ceil() and floor() not usable)

Hello, I want to convert a floating point value to its integer representation. As this will be used in comparisons, the default rounding mode (round_to_nearest) is not appropriate for me. As far as I know I can't specify the rounding mode to the FPU in a C++ standard compliant way (not even in C++0x). What are the other ways to accompli...

How to convert a special float into a fraction object

I have this function inside another function: def _sum(k): return sum([(-1) ** v * fractions.Fraction(str(bin_coeff(k, v))) * fractions.Fraction((n + v) ** m, k + 1) for v in xrange(k + 1)]) When i call fractions.Fraction on bin_coeff it reports me this error: ValueError: Invalid literal for Fraction: '1.05204948186e+12' Ho...

Float property non-zero default, is it possible?

Hi, I would like to use a float property in my component, but set it to some non-zero default value (let's say it is 1000.0). If I try to do this in the Create, the property start to behave wildly since the default value for floats it 0 (see classes.TWriter.WriteProperty.WriteFloatProp.IsDefaultValue) so when I override some value with ...

Overlap two Divs using float

I need to create following page layout using Divs. http://jsfiddle.net/6Lanq/ (please use horizontal and vertical scrollbar to see the exact picture. we have four zones) I accomplished it using nested divs and float but nested divs are not what is required. Other way of doing, that I know, is declaring "position:absolute" and setting z...

Float to text behavior of MATLAB's fprintf()

When using fprintf to convert floats to text in a decimal representation, the output is a series of decimal digits (potentially beginning with 0). How does this representation work? >>fprintf('%tu\n',pi) >>1078530011 >>fprintf('%bu\n',pi) >>04614256656552045848 Apologies if this is very trivial; I can't find an answer elsewhere, in ...

prevent floating divs from wrapping

<style> .header { float:left; width:50%; border:1px solid black; } </style> <div style="width:100%;"> <div class="header">Hello</div> <div class="header">World</div> </div> I want the two inner divs to appear beside each other fitting perfectly inside the parent. This happens when there is no border set on them, b...

Comparison of float and double variables

Possible Duplicates: Difference between float and double strange output in comparision of float with float literal I am using visual C++ 6.0 and in a program I am comparing float and double variables For example for this program #include<stdio.h> int main() { float a = 0.7f; double b = 0.7; printf("%d %d...

C# String to Float Conversion

Hi there, I need to convert a string to a float. These is is my example string: 1 MW +00000.00 mm 2 MW +0000.000 mm 3 MW -00000.01 mm 4 MW +00000.00 mm 5 MW +00002.92 mm 6 MW +00002.69 mm And this is what i'm doing: text = text.Substring(pos + 5, 9).Trim(); float val = 0.0F; float.TryParse(texto, out val); this.txtDi...

CSS - floating LIs - bigger content messes up the next row.

<style> ul{margin:0px;padding:0px;} ul li{margin:0px 5px 5px 0px;padding:0px;list-style-type:none;float:left;} </style> <ul class="clearfix"> <li>&nbsp;</li> <li>&nbsp;</li> <li>&nbsp;</li> <li>&nbsp;</li> <li>&nbsp;</li> <li>&nbsp;</li> </ul> The first li contains more content than the rest. So, I have the fo...

Truncate a float in Erlang

Hi, I am using a function to create a list from a float. float_to_list(0.02). It returns: "2.00000000000000000000e-002" I need it to give me a number exactly like: "0.20" If I fed it 5.23 "5.23" If I fed it 5.5 "5.50" So basically the number rounded to two decimal places. Probably an easy fix. Thanks EDIT: I would like t...

Internet Explorer Background Repeat on container for floating elements

I am attempting to build a gallery page for a website I am working on, Internet Explorer 8 compatibility is a must. After building the script out for the page, I take a look in internet explorer and run into this interesting issue. It seems that my background image is running fine until suddenly it just stops. I have no idea why this is ...

padding when a floated object element is inside

i have the below html: <div class="wrapper"> <div id="header"> <img alt="Giannis Simeonidis" src="logo2.png" width="300" height="220"/> <object width="550" height="200" id="banner"> <param name="movie" value="banner.swf" /> <embed src="banner.swf" width...

TextCtrl -> Truncate a float in Erlang

My last question leads me to this one: wxTextCtrl:setValue( TcGrossProfit, io_lib:format("~.2f",[NewGrossProfit])), generates an error from wxTextCtrl, with a bad arg. I know this is the culprit NewGrossProfit = 5.45333, io_lib:format("~.2f",[NewGrossProfit]) Thanks for the last one, hope this one's easier -B EDIT Last Questi...

In IE6, how to float item to right without clearing it?

In IE6, HTML is as under: <div id="topmenu"> <ul> <li>num 1</li> <li>num 2</li> </ul> <div id="rightItem">Hello World</div> </div> The CSS is as under: #rightItem { cursor: pointer; float: right; clear: none; height: 100%; width: 340px; } #topmenu { margin: 0 auto; text-ali...

NSData Bytes to Float - iPhone SDK

Hello everyone, Is there any way I can convert the value of a [NSData bytes] to a float so that I can add it to a progress bar? Thanks, Kevin ...

Ibatis+Oracle: How to update a float value

I'm trying to update a float value in oracle database, but the saved value is only the integer part of the float value. I'm using the expression update TABLE SET VALUE = #value:NUMERIC# WHERE ID = #id# The Value is defined as Number(19,4) NULL ...

NSArry of floats issue

Hi, Im trying to create an NSArray of floats. However, once the value is added to the arrays it is alway 0.0000000. What am i doing wrong? NSLog(@"percent: %f" , percent); prints the correct value and NSLog(@"timeArray: %f", [timeArray objectAtIndex:i]); is always 0.00000. NSMutableArray *timeArray = [[NSMutableArray alloc] ...

Top margin float when resizing browser

Okay so I have have a basic HTML page with a number of images: img { display: inline; float: left; height: 150px; } All works fine unless the browser width is resized to near the edge of the furthest right image, at which point it the last image jumps down a few pixels, see below images: http://i.imgur.com/1TR38.gif Firefox 3, tried ...

Multiplying strs and numbers?

Possible Duplicate: Python - Parse String to Float or Int I want to know how I can multiply raw input by a certain number. This is what I have so far: dog = raw_input("Dog:") multiply = (dog * 2) print multiply The result is (let's say I chose 10 as the raw input): 1010 I know why I'm getting this, because python is taki...

Objective-C problems performing math on an integer

I have the following line of code which is running on a timer: NSLog( @" seconds: %i, elapsedhours %f", [self elapsedSeconds], [self elapsedSeconds] / 3600); It prints out: seconds: 0, elapsedhours 0.000000 seconds: 1, elapsedhours 0.000000 seconds: 2, elapsedhours 0.000000 seconds: 3, elapsedhours 0.000000 I'm wondering why elapse...