floating-point

How to get rid of minus sign from signed zero

I am using asin to calculate the angle. The code is as below : double FindAngle(const double theValue) { return asin(theValue); } FindAngle returns a -0.0 (signed zero), when the argument theValue = -0.0. Now, how do i get rid of the minus sign from the return value. ...

HELP - IEEE - 754 - extract, normalized, NAN, etc..

~ Please forgive me - I had a previous post called IEEE - 754 - find signbit, exponent, frac, normalized, etc.. However, i had not registered my nic and i cant edit it. ( so the post is basically dead to me) Can someone delete it? My question is unanswered also. So i am posting this with different code. i still need lots of help...

Simple calculation problem with Flex

Im having a trouble with the flex calculation, im trying to transform a pixel value to mm and reversing it. Starting out with 69.8: Calculating MM to pixel from: 69.8 mm 69.8*300 = 20940 20940 / 2.54 = 8244.094488188975 8244.094488188975 / 10 = 824.4094488188975 And calculating back: Calculating pixel to MM from: 824.4094488188975 8...

How do I read 64-bit IEEE Standard 754 double-precision numbers from binary data?

I have a stream of data which consists of 64-bit IEEE standard 754 floating point numbers. How would I read these as doubles in using C#? Is there a way to convert a long/ulong into a double? ...

Floating point inaccuracy examples

How do you explain floating point inaccuracy to fresh programmers and laymen who still think computers are infinitely wise and accurate? Do you have a favourite example or anecdote which seems to get the idea across much better than an precise, but dry, explanation? How is this taught in Computer Science classes? ...

Arbitrary precision Float numbers on JavaScript

I have some inputs on my site representing floating point numbers with up to ten precision digits (in decimal). At some point, in the client side validation code, I need to compare a couple of those values to see if they are equal or not, and here, as you would expect, the intrinsics of IEEE754 make that simple check fails with things li...

Java Float become 0.0 after adding to ArrayList<T>

I have the following object : class Repeat{ private long startIndex; private long endIndex; private int length; private float repetitions; private float period; private int errors; private float percentOverlap; public void setPercentOverlap(float percentOverlap) { this.percentOverlap = percentOve...

What is a good way to show a floating point number via SNMP?

I am coding an SNMP Agent. I need to send values that have a decimal point to an SNMP Manager. I have a couple options: Truncate the number. Multiply by a constant. Ask Stackoverflow. If I truncate the number I lose a lot of information that I need. If I multiply by a constant, then the manager will display strange units that the ...

ArithematicException in Java

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

Long Integer and Float

If a Long Integer and a float both take 4 bytes to store in memory then why are their ranges different? ...

What are the other NaN values?

The documentation for java.lang.Double.NaN says that it is A constant holding a Not-a-Number (NaN) value of type double. It is equivalent to the value returned by Double.longBitsToDouble(0x7ff8000000000000L). This seems to imply there are others. If so, how do I get hold of them, and can this be done portably? To be clear, I woul...

POVray: How to reliably create nice merges of objects merely touching on the surface?

What I'm doing I have a scene which algorithmically draws a prism with a hexagonal cross-section and n layers of such prisms surrounding the center one, such that all the prisms together make a larger hexagon shape. Now, each row of prisms is displaced from the next by a multiple of sqrt(3)/2 (because the dimensions of one prism are <...

MPFR, printf, decimal places, locales, file i/o problem

A user of my program has reported problems reading a settings file written by my program. I looked at the settings file in question and instead of decimal points using the period "." it uses commas ",". I'm assuming this is to do with locales? The file i/o is using fprintf and mpfr_out_str for file output and getline combined with ato...

How to convert strings to floats with perfect accuracy?

I'm trying to write a function in the D programming language to replace the calls to C's strtold. (Rationale: To use strtold from D, you have to convert D strings to C strings, which is inefficient. Also, strtold can't be executed at compile time.) I've come up with an implementation that mostly works, but I seem to lose some precisi...

Is there an open-source c/c++ implementation of IEEE-754 operations?

Hi, I am looking for a reference implementation of IEEE-754 operations. Is there such a thing? ...

Floating point library for embedded application

I'm developing program for Cortex-M3. It doesn't have floating point coprocessor. Standard C library can emulate floating point operations, but I don't use it due to its size. Is there any good and free c library, which can emulate floating point arithmetics, targeted on ARM processors? Currently, when I use floating point operators I h...

Double to int conversion behind the scene?

I am just curious to know what happens behind the scene to convert a double to int, say int(5666.1) ? Is that going to be more expensive than a static_cast of a child class to parent? Since the representation of the int and double are fundamentally different is there going to be temporaries created during the process and expensive too. ...

Big float for shader-based mandelbrot explorer

Hi All, I've managed to create a simple mandelbrot explorer using Open Gl, and the CGFX SDK provided by NVidia. It works well, but is currently float based, and therefore doesn't have much "depth" -- As the distance from the lowest complex number to the largest becomes smaller, the precision is lost, and the resultant image is "pixelate...

How to convert a floating point to hexadecimal (and back) in Delphi

Possible Duplicate: Converting float or negative integer to hexadecimal in Borland Delphi Is there a function i can use to convert a floating point value to a hexadecimal value and back? ...

bounding reciprocal of a number

Hi, I have met several cases where people computing reciprocal of a number with very small absolute value. They say the result should be upper bounded, since the reciprocal is very big. (1) I wonder about the reason why is that? e.g. in page 18 of this paper http://www-stat.stanford.edu/~tibs/ftp/boost.ps, the first paragraph, the re...