float

Can bad stuff happen when dividing 1/a very small float?

If I want to check that positive float A is less than the inverse square of another positive float B (in C99), could something go wrong if B is very small? I could imagine checking it like if(A<1/(B*B)) but if B is small enough, would this possibly result in infinity? If that were to happen, would the code still work correctly in al...

What is the cost in bytes for the overhead of a sql_variant column in SQL Server?

I have a table, which contains many columns of float data type with 15 digit precision. Each column consumes 8 bytes of storage. Most of the time the data does not require this amount of precision and could be stored as a real data type. In many cases the value can be 0, in which case I could get away with storing a single byte. My goal...

CGFloat vs GLfloat

I understand CGFloat should be used in Cocoa applications to make them 64-bit clean. But what about in a simple OpenGL game that uses Cocoa/Objective-C for everything but the rendering (to an NSOpenGLView)? CGFloat is a part of Core Graphics, so if I would it also be alright to use CGPoint, CGRect etc.? or should I just write rects and v...

fesetround with MSVC x64

I'm porting some code to Windows (sigh) and need to use fesetround. MSVC doesn't support C99, so for x86 I copied an implementation from MinGW and hacked it about: //__asm__ volatile ("fnstcw %0;": "=m" (_cw)); __asm { fnstcw _cw } _cw &= ~(FE_TONEAREST | FE_DOWNWARD | FE_UPWARD | FE_TOWARDZERO); _cw |= mode; //__asm__ volatile ("f...

convert string to float without silent NaN/Inf conversion

I'd like convert strings to floats using Python 2.6 and later, but without silently converting things like 'NaN' and 'Inf' to float objects. I do want them to be silently ignored, as with any text that isn't valid as a float representation. Before 2.6, float("NaN") would raise a ValueError on Windows. Now it returns a float for which ...

Function for flipping the sign of a number

How can I change the sign of a number? abs(); will not return me a negative when the input is positive, correct? I need the opposite sign. ...

Latex two captioned verbatim environments side-by-side

How to get two verbatim environments inside floats with automatic captioning side-by-side? \usepackage{float,fancyvrb} ... \DefineVerbatimEnvironment{filecontents}{Verbatim}% {fontsize=\small, fontfamily=tt, gobble=4, frame=single, framesep=5mm, baselinestretch=0.8, labelposition=topli...

IE7 - jquery addClass() breaks floating elements

I have this nav that uses addClass('hover') when the mouse is rolled over an item. This works fine except in IE7 when the addClass function is called every element with float:left stops floating and the page totally loses its structure. This is my JS: _this.position_sub_menus = function(){ $('#header #nav > ul > li').mouseenter( ...

Cast string with coma to float with dot

Hello ! When I try to cast $value = floatval('14,5833'); to a float type I expect a value with dot like 14.5833 but it returns me 14,5833. How should I do this ? I wouldn't like to use any string replace functions. ...

I'm trying to stop the PHP function which takes my form input value and rounds to the nearest Integer.

NOTE: This is from a Joomla component. The Problem: When I enter, say, 4.90 into the price input box and hit save the price becomes 5, etc. I need for the value to remain as entered. I've tracked down this block of code in the form.php looks like it might be the right one, but I can't figure out what needs to change: function toTran...

How to find out the format of a float?

I'm working with someone else's code, and there is a float with some unusual qualities. If I output the float using: NSLog(@"theFloat: %f", record.theFloat); I get: theFloat: 0.000000 However, if I use: NSLog(@"(int)theFloat = %i", (int) record.theFloat); I get: (int)theFloat: 71411232 How do I discover the real format and v...

Strange layout behaviour

I am a little bit confused. Here is a small web page. There are two main div-s: top and mainBlock. First contains an image. The problem is that firebug shows that div#top's height is equal to 0 and because of that the next div mainBlock moves up. If I would delete this piece of code: div#logo{ float: left; } everything will start...

IE 7 floated div auto-clearing next element ?

Hello, I'm having trouble with the following example. Background: I first have a element floated to the right with an image output inside it. I then have a element with other content within it. In FF and IE 8, as expected, the .images div floated to the right displays floated to the right pushing the content within the .product-bo...

Determine precision and scale of particular number in Python

I have a variable in Python containing a floating point number (e.g. num = 24654.123), and I'd like to determine the number's precision and scale values (in the Oracle sense), so 123.45678 should give me (8,5), 12.76 should give me (4,2), etc. I was first thinking about using the string representation (via str or repr), but those fail f...

Write TIFF float images using CImg

Hi! I'm using CImg and I have noticed that I cant write TIFF images with float data. CImg wrotes them as 1byte/per pixel integer images. ¿Does anyone know if it is possible to write float images? Or, do you know other lib to do it. ...

Clearing block affects wrong floating

I've got two-column layout <div class="left-pane"> Left pane </div> <div class="central-pane"> <div> <ul class="customers-types-tabs"> <li>item 1</li> <li>item 2</li> <li>item 3</li> </ul> </div> <div>Main content</div> <...

Test assertions for tuples with floats

I have a function that returns a tuple that, among others, contains a float value. Usually I use assertAlmostEquals to compare those, but this does not work with tuples. Also, the tuple contains other data-types as well. Currently I am asserting every element of the tuple individually, but that gets too much for a list of such tuples. Is...

TSQL - make a literal float value

I understand the host of issues in comparing floats, and lament their use in this case - but I'm not the table author and have only a small hurdle to climb... Someone has decided to use floats as you'd expect GUIDs to be used. I need to retrieve all the records with a specific float value. sp_help MyTable -- Column_name Type Comp...

Android Float To Int

Why is this soo hard to find out? public boolean onTouch(View v, MotionEvent event) I need to convert float event.getY() to and int. Is this possible. event.getY().intValue() will not work at all. Any ideas? ...

Float32 to Float16

Can someone explain to me how I convert a 32-bit floating point value to a 16-bit floating point value? (s = sign e = exponent and m = mantissa) If 32-bit float is 1s7e24m And 16-bit float is 1s5e10m Then is it as simple as doing? int fltInt32; short fltInt16; memcpy( &fltInt32, &flt, sizeof( float ) ); fltInt16 = (fltInt32 &...