float

Best way to generate a random float in C#

What is the best way to generate a random float in C#? Update: I want random floating point numbers from float.Minvalue to float.Maxvalue. I am using these numbers in unit testing of some mathematical methods. ...

IE7 Clear Float Issue

Hi this is a simplified version of an issue I'm having with IE7. Basically the divs following the cleared div (green) don't behave as expected (in IE7). It works as expected in Safari, FF etc and IE8. Does anybody have any advice for a fix. Thanks for any help :) <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3....

Migration conversion of float data to decimal data

I am migrating data from one table to a new table. The old table uses FLOAT, and in the new table I am using DECIMAL as the field attribute. I am using the following statement which worked fine: CAST(OLD_COLUMN_NAME as DECIMAL(9,2) AS 'NEW_COLUMN_NAME' that works like a charm until I hit the bump in the road. The old data is defined as...

How do I prevent floated-right content from overlapping main content?

I have the following HTML: <td class='a'> <img src='/images/some_icon.png' alt='Some Icon' /> <span>Some content that's waaaaaaaaay too long to fit in the allotted space, but which can get cut off.</span> </td> It should display as follows: [Some content that's wa [ICON]] I have the following CSS: td.a span { overflow: hidde...

How to make float values in Python display .00 instead of .0 ?

Simple question, sorry I can;t figure this out. I have some numbers that are made by float(STRING) and they are displayed as xxx.0, but I want them to end in .00 if it is indeed a whole number. How would I do this? Thanks! EDIT: Python saiys that float doesn't have a cal 'format()' ...

CSS float bug with side pane resizing main content

Hi! We're having a problem with a side pane that is floated to the right. This pane somehow resizes the first div in the main content, so the div is stretched to the same height as the pane, see illustration below. The main div has the following css margin: 10px 280px 0 10px; padding-right: 50px; The side pane has the following css ...

How can I get the <form> div to properly wrap my two <input type="button"> buttons?

Hello, For some reason my Submit and Cancel buttons are not being wrapped in the form tag like I expect them to be (based on their position with in the form tag in the HTML) when I have their float property set to right and left respectively. The two buttons are positioned just outside & below the form div to the far right & left sides....

php read from file float

Hello I have a text file with three lines. every line has a float number. How can I take each value and put in a float variable even if array? For example text file is like the following +3.01\n -0.0012\n -0.1\n I want an array [if it possible] which save the values as float not as string. Thanks ...

Does printf() depend on order of format specifiers?

#include<stdio.h> main() { float x=2; float y=4; printf("\n%d\n%f",x/y,x/y); printf("\n%f\n%d",x/y,x/y); } Output: 0 0.000000 0.500000 0 compiled with gcc 4.4.3 The program exited with error code 12 ...

CSS Layout full of random sized divs

I'm trying to create a layout that is backward from what I usually do. I have hundreds of randomly sized divs that I want to fill in as much of the page as possible. As a quick hack, it might look something like this: |--------||-------------------||----||-----------| | || 2 || 3 || 4 | | 1 ||-------...

PHP unexpected result of float to int type cast

I'trying to convert a float to an int value in php: var_dump((int)(39.3 * 100.0)); //Returns 3929 but should be 3930! var_dump((int)(39.2 * 100.0)); //Returns 3920 I can use ceil to make it work but can somebody explain this to me? var_dump((int)ceil(39.3 * 100.0)); //Returns 3930 ...

CUDA float to long long conversion and texture read giving incorrect result.

I would ask this in the CUDA forums but for some reason I can't get past the first page the registration, so here goes: nVidia Card: 9800 GT CUDA toolkit 3.0 Compiled for: compute capability 1.1 Scenario 1: float result = 0; float f1 = tex2D( tex, u, v ); float f2 = tex2D( tex, u + 1; v + 1 ); long long ll1 = __float2ll_rn...

Make child visible outside an overflow:hidden parent

In CSS the overflow:hidden is set on parent containers in order to allow it to expand with the height of their floating children. But it also has another interesting feature when combined with margin: auto... If PREVIOUS sibling is a floating element, it will actually appear juxtapose to it. That is if the sibling is float:left then the ...

optimization, branching elimination

float mixValue = ... //in range -1.0f to 1.0f for(... ; ... ; ... ) //long loop { float inputLevel = ... //in range -1.0f to 1.0f if(inputLevel < 0.0 && mixValue < 0.0) { mixValue = (mixValue + inputLevel) + (mixValue*inputLevel); } else { mixValue = (mixValue + inputLevel) - (mixValue*inputLevel)...

ie6 float causes background image to dissapear

Hi Guys, I have a div with a background image which is aligned bottom right. Then I have another div floated inside that div to the left and to the bottom. In IE6, it looks like the bottom inner div is overlapping and cutting out the middle of the background image which is set to bottom left. Any ideas what might cause this? Is there a...

How can i overlay an 10x10px image on top of another image?

Hi Guys, I have a user avatar on my website. Simple image tag: <img src="foo.jpg" class="userphoto" width="48" height="48" alt=""> Now, i want to float an image (Facebook Icon - 10x10px) over this image on the top left corner of the image. This is to signify that the user is authenticated to Facebook. How can i do this? CSS styling...

CSS Overflow Hidden Workaround?

Wondering if anyone has a work around for this issue. I've got a markup like this: <div id="outer"> <div id="inner"> content here </div> </div> now my inner div isnt always extending as far as I would like it. Overflow: hidden; works wonders, but in this case I have some elements that overlap the edge so I cant use that. Float:lef...

C# Converting a string containing a floating point to an integer

What is the best way to take a string which can be empty or contain "1.2" for example, and convert it to an integer? int.TryParse fails, of course, and I don't want to use float.TryParse and then convert to int. Thanks! ...

Is it safe to use floats as keys of hashtables?

I need to store pairs of float,int in which the int value stores the number of occurrences of a float value inside a model I'm using for a tool I'm developing and I was wondering if it's safe to do such things.. Finite precision should be an issue when talking floats used to direct comparisons (or as content to be hashed) so I think tha...

what will be behavior of following code snippet ?

What will be the behavior and output of the following code if i accidentally code so in C/C++, float a = 12.5; printf("%d\n", a); printf("%d\n", *(int *)&a); ...