Search Results

Search found 950 results on 38 pages for 'floating'.

Page 11/38 | < Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >

  • Fast sign in C++ float...are there any platform dependencies in this code?

    - by Patrick Niedzielski
    Searching online, I have found the following routine for calculating the sign of a float in IEEE format. This could easily be extended to a double, too. // returns 1.0f for positive floats, -1.0f for negative floats, 0.0f for zero inline float fast_sign(float f) { if (((int&)f & 0x7FFFFFFF)==0) return 0.f; // test exponent & mantissa bits: is input zero? else { float r = 1.0f; (int&)r |= ((int&)f & 0x80000000); // mask sign bit in f, set it in r if necessary return r; } } (Source: ``Fast sign for 32 bit floats'', Peter Schoffhauzer) I am weary to use this routine, though, because of the bit binary operations. I need my code to work on machines with different byte orders, but I am not sure how much of this the IEEE standard specifies, as I couldn't find the most recent version, published this year. Can someone tell me if this will work, regardless of the byte order of the machine? Thanks, Patrick

    Read the article

  • Change column height as other column gets longer

    - by Infiniti Fizz
    Hi, I have tried a few things to solve this problem but I can't seem to get it working. The problem is that I have 2 columns as the main part of my website, right and left. On some pages, there is a lot of text in the left column, therefore it is very long, the problem is that the right column doesn't elongate with the left column. Both columns have the same background colour and a footer s displayed across the width of both columns after the columns finish. My first thought was to put both columns inside a div which would have the same background colour as them and therefore if the left column became 1500px long in total and the right column stayed at around 600px (due to the elements inside it) then this wouldn't show as the new, outer div would elongate along with the left column. But for some reason this didn't work. Could it be because the columns are floated? Does anyone have any other ideas? Here is the website (Obviously not finished yet): Beansheaf Hotel I have chosen a page where there is a lot of text in the left column so the problem is apparent. Thanks in advance, InfinitiFizz

    Read the article

  • Compare sign of two doubles

    - by bobobobo
    What's the fastest way to compare sign on a double? I know that a double has a "sign bit" but I'm not sure if the way I'm "looking for it" in its binary rep is a good idea or not. Barring "portability" issues, can someone tell me what's going on with this code in MSVC++? #include <stdio.h> int main() { double z = 5.0 ; __int64 bitSign ; __int64 *ptr ; ptr = (__int64*)&z ; for( __int64 sh = 0 ; sh < 65 ; sh++ ) { bitSign = 1L << sh ; // Weird. it doesn't do 1. printf( "Bit# %d (%llx): %lld\n", sh, bitSign, ( (*ptr) & bitSign) ) ; } } First, why is starting at bit 32, even though I only shifted by one bit? Second, is it ok for me to check the 64th bit of a double to check its sign on MSVC++? Or is there a more preferred way?

    Read the article

  • sin v/s sinf fucntion in C

    - by user319873
    Hi Guys, I am trying to use sinf function in my C Program and it does give me undefined reference under MSVC 6.0 but sin works fine. This make me curious to find the difference between sin and sinf. What is the logical difference between sin and sinf(). How can I implement my own sinf functionality?

    Read the article

  • How do I find hash value of a 3D vector ?

    - by brainydexter
    I am trying to perform broad-phase collision detection with a fixed-grid size approach. Thus, for each entity's position: (x,y,z) (each of type float), I need to find which cell does the entity lie in. I then intend to store all the cells in a hash-table and then iterate through to report (if any) collisions. So, here is what I am doing: Grid-cell's position: (int type) (Gx, Gy, Gz) = (x / M, y / M, z / M) where M is the size of the grid. Once, I have a cell, I'd like to add it to a hash-table with its key being a unique hash based on (Gx, Gy, Gz) and the value being the cell itself. Now, I cannot think of a good hash function and I need some help with that. Can someone please suggest me a good hash function? Thanks

    Read the article

  • Float: left not showing up after a certain point.

    - by Bobby K
    http://test.jptgraphics.com/products?cat=APPAREL This works fine in Safari but shows incorrectly in the latest version of Firefox ( was fine in 3.5) and in some versions of IE. In the middle column the product thumbnails drop down below when the 'float: left;' parameter is used. It is as if it is being escaped by a tag from that point forward no 'float: left's work and all the items are centered moving forward.

    Read the article

  • Inaccurate Logarithm in Python

    - by Avihu Turzion
    I work daily with Python 2.4 at my company. I used the versatile logarithm function 'log' from the standard math library, and when I entered log(2**31, 2) it returned 31.000000000000004, which struck me as a bit odd. I did the same thing with other powers of 2, and it worked perfectly. I ran 'log10(2**31) / log10(2)' and I got a round 31.0 I tried running the same original function in Python 3.0.1, assuming that it was fixed in a more advanced version. Why does this happen? Is it possible that there are some inaccuracies in mathematical functions in Python?

    Read the article

  • x86-64 long double precision

    - by aaa
    hello. What is the actual precision of long double on Intel 64-bit platforms? is it 80 bits padded to 128 or actual 128 bit? if former, besides going gmp, is there another option to achieve true 128 precision?

    Read the article

  • Contact form contents spilling out of container div on window resize.

    - by Alex C
    I'm trying to get my contact form to not spill its contents out of the parent div when I resize the viewport. How can I go about doing this? I have used float clearing to prevent this as I understood it was supposed to be used, but it isn't working. What should I do to fix this? here is the page in question. also I have a similar problem with the header.. the menu drops below the header text if I make the browser window smaller. Thanks for any help you all have to offer. http://countercharge.net/catsite/index.php?P=contact

    Read the article

  • Reducing decimal places in Delphi

    - by Hendriksen123
    I am storing a list of numbers (as Double) in a text file, then reading them out again. When I read them out of the text file however, the numbers are placed into the text box as 1.59993499 for example, instead of 1.6. AssignFile(Pipe, 'EconomicData.data'); Reset(Pipe); For i := 1 to 15 Do ReadLn(Pipe, SavedValue[i]); CloseFile(Pipe); Edit1.Text := FloatToStr(SavedValue[1]); The text in Edit1.text, from the code above, would be 1.59999... instead of the 1.6 in the text file. How can i make it so the text box displays the original value (1.6)?

    Read the article

  • Faster float to int conversion in Python

    - by culebrón
    Here's a piece of code that takes most time in my program, according to timeit statistics. It's a dirty function to convert floats in [-1.0, 1.0] interval into unsigned integer [0, 2**32]. How can I accelerate floatToInt? piece = [] rng = range(32) for i in rng: piece.append(1.0/2**i) def floatToInt(x): n = x + 1.0 res = 0 for i in rng: if n >= piece[i]: res += 2**(31-i) n -= piece[i] return res

    Read the article

  • negative precision values in ostream

    - by daz-fuller
    This is more of a question of curiosity but does anyone know how negative precision values are handled in C++? For example: double pi = 3.14159265; cout.precision(-10); cout.setf(ios::fixed, ios::floatfield); cout << pi << endl; I've tried this out and using GCC and it seems that the precision value is ignored but I was curious if there is some official line on what happens in this situation.

    Read the article

  • jQuery: Combining "filterable portfolio" and Masonry layout

    - by katharina
    Hi, I'm trying to combine the "filterable portfolio" (http://net.tutsplus.com/tutorials/javascript-ajax/creating-a-filterable-portfolio-with-jquery/) with the Masonry layout ... so I want my items to readjust with masonery after I filtered them, but they stay in the position where masonery put them... here's my very rough first website draft: http://waynetest.kilu.de/lula/ (work obviously in progress..;)) Is there a possibility to combine both js-scripts? thanks a lot, katharina

    Read the article

  • Dynamic margin (or simulation of margin) between left floated divs

    - by BugBusterX
    I have a number of divs floated left. When browser is resized they move down or up based on how many can fit on the line. I was wondering if there is a way to dynamically (with css) have those divs align (or have margin) in a way, that they would always fill the entire screen space by having their marhin resize? In other words margin between them would resize while browser is resized, but as soon as another div can fit it will be added in the line, or if minimum margin is reached and passed another div goes to next line while margins expand again. Here's an example how it is now, resize the wondow to see he leftover space that I want to "fill" <html> <head> <style> .test { float:left; width: 100px; height:100px; background-color: grey; margin: 0 10px 10px 0; } </style> </head> <body> <div class="test"></div> <div class="test"></div> <div class="test"></div> <div class="test"></div> <div class="test"></div> <div class="test"></div> <div class="test"></div> <div class="test"></div> <div class="test"></div> <div class="test"></div> <div class="test"></div> <div class="test"></div> </body> </html>

    Read the article

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

    - by Jeremybub
    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 all situations? in a similar vein, I might do if(1/A>B*B) Which might be slightly better because B*B might be zero if B is small (is this true?) Finally, a solution that I can't imagine being wrong is if(sqrt(1/A)>B) Which I don't think would ever result in zero division, but still might be problematic if A is close to zero. So basically, my questions are Can 1/X ever be infinity if X is greater than zero (but small)? Can X*X ever be zero if X is greater than zero? Will comparisons with infinity work the way I would expect them to?

    Read the article

  • C/C++ - Convert 24-bit signed integer to float

    - by e-t172
    I'm programming in C++. I need to convert a 24-bit signed integer (stored in a 3-byte array) to float (normalizing to [-1.0,1.0]). The platform is MSVC++ on x86 (which means the input is little-endian). I tried this: float convert(const unsigned char* src) { int i = src[2]; i = (i << 8) | src[1]; i = (i << 8) | src[0]; const float Q = 2.0 / ((1 << 24) - 1.0); return (i + 0.5) * Q; } I'm not entirely sure, but it seems the results I'm getting from this code are incorrect. So, is my code wrong and if so, why?

    Read the article

  • erroneous Visual C float / double conversion?

    - by RED SOFT ADAIR
    In Visual C++ i wrote the following sample in a C++ program: float f1 = 42.48f; double d1 = 42.48; double d2 = f1; I compiled the program with Visual Studio 2005. In the debugger i see the following values: f1 42.480000 float d1 42.479999999999997 double d2 42.479999542236328 double d1 by my knowledege is OK, but d2 is wrong. The problem occurs as well with /fp=precise as with /fp=strict as with /fp=fast. Whats the problem here? Any hint how to avoid this Problem? This leads to serious numerical problems.

    Read the article

  • How do calculators work with precision?

    - by zoul
    Hello! I wonder how calculators work with precision. For example the value of sin(M_PI) is not exactly zero when computed in double precision: #include <math.h> #include <stdio.h> int main() { double x = sin(M_PI); printf("%.20f\n", x); // 0.00000000000000012246 return 0; } Now I would certainly want to print zero when user enters sin(p). I can easily round somewhere on 1e–15 to make this particular case work, but that’s a hack, not a solution. When I start to round like this and the user enters something like 1e–20, they get a zero back (because of the rounding). The same thing happens when the user enters 1/10 and hits the = key repeatedly — when he reaches the rounding treshold, he gets zero. And yet some calculators return plain zero for sin(p) and at the same time they can work with expressions such as (1e–20)/10 comfortably. Where’s the trick?

    Read the article

  • How to mark empty in a single element in a float array

    - by Vineeth Mohan
    I have a large float (primitive) array and not every element in the array is filled. How can i mark a particular element as EMPTY. I understand this can be achieved by some special symbols but still i would like to know the standard way. Even if i am using some special symbol , how will i handle a situation where the actual data item is the value of special symbol. In short my question is how to implement the NULL feature in a primitive type array in java. PS - The reason why i am not using Float object is to achieve a high memory and speed performance. Thanks Vineeth

    Read the article

< Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >