float

C# float bug? 0.1 - 0.1 = 1.490116E-08

What's going on?! Subtraction works fine until I get to 0.1 - 0.1. I'm in visual c# 2008 using the nonoba.com API. Console.WriteLine("hit! " + Users[targetNum].character.health + " : " + player.character.profile.attackPower); Users[targetNum].character.health -= player.character.profile.attackPower; Console.WriteLine("health! " + User...

PHP String to Float

I am not familiar with PHP at all and had a quick question. I have 2 variables @pricePerUnit and @invoicedUnits. Here's the code that is setting these to values: $InvoicedUnits = ((string) $InvoiceLineItem->InvoicedUnits); $pricePerUnit = ((string) $InvoiceLineItem->PricePerUnit); If I output this, I get the correct values. Lets say ...

Is there a function to round a float in C or do I need to write my own?

Is there a function to round a float in C or do I need to write my own? float conver= 45.592346543; Would like to round actual value to one decimal place. conver = 45.6 Thanks. ...

CSS: wrap text around a bottom-right div?

Every time I try to do something seemingly-simple in CSS, it punches me in the gut and steals my lunch money :( I've been looking at this for over an hour and haven't made a bit of progress... I have a content div that contains a 460x160 image. All I want to do is position the image at the bottom-right corner and wrap my text around it...

Problem with float and pictures in LaTex

The picture is at the position of the header: http://dl.getdropbox.com/u/175564/%20latex1.png Code: \begin{figure} \subfloat[A gull]{\label{fig:gull}\includegraphics[width=0.15\textwidth]{p1.png}} \subfloat[A tiger]{\label{fig:tiger}\includegraphics[width=0.15\textwidth]{p2.png}} \caption{Pictures of animals} \label{f...

Float in Database to ? in .NET

If you have a float in MSSQLServer, to what do you map this in .NET? Can you convert it to Double or will you loose numbers? thx, Lieven Cardoen ...

SIMD on an Array of Doubles?

I'm doing some work where SIMD is required and I need to do operations on an array of doubles. Do any of the mainstream architectures support this? I've only seen floating point operations. Thanks in Advance, Stefan ...

SQL Convert float to comma varchar with decimals

I have a couple floats that are kinda big. They're around a 100 million. I would like this number to show like the following 123,456,789.01234 I've found that I can use CONVERT if its a money datatype but this doesn't do the full trick (it leaves off some decimal places). I have to have commas on the left and five decimal places on th...

Float 2 divs in a parent div and arrange such divs one below another

Hi, I am creating a web page with 3 columns. The middle column is where all the content goes. The content I want to enter has to be in the format of left aligned image, followed by some text next to the image. And this flows throughout the column with different images and corresponding text. Since my layout is a div based layout, I have...

CSS Floating w/ Overlap

I'm trying to set up a simple horizontal tab structure for a page I'm working on, and I'm running into some trouble with floating div's combined with z-index that I'm hoping someone can help me with. Viewing the following code in a browser: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/...

Convert/Quantize Float Range to Integer Range

Say I have a float in the range of [0, 1] and I want to quantize and store it in an unsigned byte. Sounds like a no-brainer, but infact it's quite compliated: The obvious solution looks like this: unsigned char QuantizeFloat (float a) { return (unsigned char) (a * 255.0f); } This works in so far that I get all numbers from 0 to 25...

Why does IE7 display my webpage incorrectly?

If you look at www.kwikhousesale.co.uk in any FF, Google Chrome, Opera, IE8 etc. it displays fine. However, when using IE7 all the text shifts to the right resulting in much of the text appearing off the page. Please could somebody help me to resolve this issue? ...

How to convert string into float in javascript?

I have a datagrid and I get 2 column's value by javascript. These fields are numeric and when fields have comma (ex. 554,20), I cant get the numbers after comma. I tried parseInt, parseFloat. How can I solve it? ...

Absolute value for floats in core OCaml

I am in need of an absolute value function for floats in OCaml and the core language doesn't seem to possess one, so I wrote the following: let absF (f:float) = if f > 0.0 then f else (f *. -1.0);; which seems to work for positives but not for negatives, citing: This expression has type float -> float but is here used with type int ...

CSS problem with IE - right-alignment does not work in a div inside a table cell

Float:right specified for a div inside a table cell seems to have no effect in IE. I have also tried text-align right, among other things, to align the layer contents to the right, but without success in IE 7. CSS snippet: .workloadcell { background-color: #E6D7E9; padding: 0px; width: 14px; height: 16px; text-alig...

C++ random float

How do I generate random floats in C++? I thought I could take the integer rand and divide it by something, would that be adequate enough? ...

iPhone Cocoa mixed Mode Math Basic Errors

Just realized that I am getting errors on simple math if I mixed Integer with floats in iPhone SDK on the Simulator. Two examples: float testVal1 = 10 + 5/10; //evaluates to 10 instead of 10.5 unless I use explicit 10.0f.. // Problem Code mixed float int NSUInteger jvalue = 2312345; NSInteger testVal2 = (jvalue - 2512345); // evalua...

CSS div's overlapping

I am trying to build a comments section for my website. In the comments section, I want it laid out wordpress-style, with the avatar to the left. It works, but what is happening is the comment text is wrapping around the avatar underneath. For an example, here. This probably has a simple solution to it but I am a CSS amatuer. This is the...

Stretch right float div width?

I have 2 float:left div, the first is fixed and i want the second div stretch the remain space. <div id="container"> <div id="leftform"> </div> <div id="rightform"> </div> </div> Any idea? Thanks ...

CSS Appropriate Way to Center Content

I prefer working with CSS based design, but as more of a back end coder my CSS skills are a bit weak. When I get involved with layout, I tend to fall back on table based formatting because my mind has been warped by years of table based abuse. There's one particular problem that I always trip over. What is the best CSS alternative to:...