float

What is the output of the following C code?

I meant to ask: why is the output of the following code 1 million? If the program runs indefinitely but produces no output, write INFINITE LOOP as the answer to the question. All of the programs compile and run. They may or may not contain serious errors, however. You should assume that int is four bytes. You should assume that float ha...

Floats are not saved correctly into SQLite table using PHP

Hi, I'm using SQLite 3 with PHP. The SQLite table consists of 2 INTEGER and one FLOAT column. When saving data into this table using PHP floats are not saved correctly (default value is stored instead). The two integer columns are saved. Any ideas what could be wrong? Thank you. Simplified code that actually works correctly: $conn = n...

ArithematicException in Java

In Java, (Number/0) throws an ArithematicException while (Number/0.0) = Infinity. Why is it so.? ...

C# to SQL float values conversion

Hello, I'm working with C# and SQL 2005. I've stored a float variable of the value 0.2 into table column of real type. When I opened the table to check the values, I found a value of 0.200000029... It is known problem, real is approximate type. However, I've changed the value using management studio to 0.2 and reloaded the table. The dat...

Does 64-bit floating point numbers behave identically on all modern PCs?

I would like to know whether i can assume that same operations on same 64-bit floating point numbers gives exactly the same results on any modern PC and in most common programming languages? (C++, Java, C#, etc.). We can assume, that we are operating on numbers and result is also a number (no NaNs, INFs and so on). I know there are two ...

Counting digits in a float

I am following some beginner tutorials for OpenGL in c++ but as I started off as a c# programmer it has made me take a lot of things for granted. So my problem occurred when I was debug printing my FPS reading to the output. I think the method was something like DebugPrintString off the top of my head which took a char* and basically i w...

ie7 float div height

i have this code Code: <div id="container"> <div id="products_content"> <div id="products_page_header"> <div id="products_page"> <div class="post"> <div class="entrytext"> some text </div> </div> </div> ...

Numeric code porting powerpc to intel gives different results using float.

My essential problem is how to make arithmetic with floats on x86 behave like a PowerPC, going from Classic MacOS (CodeWarrior) to Windows (VS 2008). The code in question, of which there is a lot, has a pile of algorithms which are highly iterative and numerically very sensitive. A typical complex line is: Ims_sd = sqrt((4.0*Ams*sqr(n...

Simpler way to format bytesize in a human readable way?

Hi, I came up with the following solution to format an integer (bytesize of a file). Is there any better/shorter solution? I esacially don't like the float_as_string() part. human_filesize(Size) -> KiloByte = 1024, MegaByte = KiloByte * 1024, GigaByte = MegaByte * 1024, TeraByte = GigaByte * 1024, PetaByte = TeraByte * 1024, ...

C++: Why can't I use float value as a template parameter?

When I try to use float as a template param, the compiler cries for this code, while int works fine. Is it that I cannot use float as a template parameter? #include<iostream> using namespace std; template <class T, T defaultValue> class GenericClass { private: T value; public: GenericClass() { value = defaultValue; ...

Check for equality on a MySQL Float field

I have a Joomla system and I'm trying to change the search so that it correctly finds floating point values in the database. So, I have a query that is built at runtime that looks something like this: select 'column1' from 'some_table' where 'some_float_field' <=> '2.18' This doesn't work, it never matches anything, even though I see...

Wordpress: How to compare 2 float values in meta_value column?

Hi Guys, I have about 100 posts in wordpress, all with a meta_key of price and a value. How would I go about searching through all posts with a value between 23.00 and 41.00 for example? I know that 'meta_compare ' treats 'meta_value' as a string, so I can't use this to solve my problem. Anybody have any clues? Thanks ...

How can I get an embedded video to float left in IE7?

How can I get an embedded video to float left in IE7? The following code works great in FireFox and the text wraps around the floated div and video, but in IE7 the text sits under the div/video. <object height="264" width="320" style="float: left; margin: 5px;"><param name="wmode" value="transparent"><param name="AllowFullScreen" value=...

Strange CSS float issue

I am designing a website and I am trying to have one header with two smaller headers floating next to it, one under each other. I tried doing it here, about halfway down where it says "About" and "what your saying." The about section appears correct because the smaller width pushes the next line down. BUT, on the right I cant get the te...

CSS: Floating div to right causes container div to stretch full width of screen in IE

Hi all, I saw a similar question here, and did not see an answer. I'm having an issue where an element is floated right, inside a parent div, and it's causing the div to stretch the entire width of the page in IE7. This does not happen in any other browsers (Firefox and Chrome). I've also posted pictures after the question, for referenc...

A floated image does not count toward DIV width, how can I make it so?

The following code: <div> <img src="" style="float: left;"> <p>Lorem Ipsum...</p> </div> Renders a div container with text, and a floated image on the left. Great. The text included therein also expands the div as much as it can while maintaining the text in a single line (unless otherwise writ). However, with a floated image,...

Converting string to float throws error "Incorrect format"

I can't get my application to convert a string into a float: float number = float.Parse(match); Where match is "0.791794". Why doesn't this work? The error I get is "Input string was not in a correct format.", but I can't understand what's wrong with it. ...

Css Thumbnail clear main image

If you look at the image gallery on this page you will see some thumbnails listed over a orange car main image. I can't figure out why they are appearing over the image I would like them to appear below it... The only way I can make it work is with BR's which I really don't want to do... http://c5.dealercontrol.net/events/ Thanks for a...

C# float infinite loop

The following code in C# (.Net 3.5 SP1) is an infinite loop on my machine: for (float i = 0; i < float.MaxValue; i++) ; It reached the number 16777216.0 and 16777216.0 + 1 is evaluates to 16777216.0. Yet at this point: i + 1 != i. This is some craziness. I realize there is some inaccuracy in how floating point numbers are stored. ...

CLR JIT optimizations violates causality?

I was writing an instructive example for a colleague to show him why testing floats for equality is often a bad idea. The example I went with was adding .1 ten times, and comparing against 1.0 (the one I was shown in my introductory numerical class). I was surprised to find that the two results were equal (code + output). float @float =...