Tag: floating-point
Posts of Tag: floating-point
  1. Fast exponentiation: real^real (C++ MinGW, Code::Blocks)

    I am writing an application where in a certain block I need to exponentiate reals around 3*500*500 times. When I use the exp(y*log(x)) algorithm, the program noticeably lags. It is significantly faster if I use...Learn More
    floating-pointc++exponentiation
  2. In Python small floats tending to zero

    I have a Bayesian Classifier programmed in Python, the problem is that when I multiply the features probabilities I get VERY small float values like 2.5e-320 or something like that, and suddenly it turns into 0...Learn More
    Pythonfloating-pointnumerical-stability
  3. How to check whether string might be type-cast to float in Python?

    Is there some function like str.isnumeric but applicable to float? '13.37'.isnumeric() #False I still use this: def isFloat(string): try: float(string) return True except ValueErr...Learn More
    Pythonfloating-point
  4. How can I declare a class variable as floating point in Moose?

    How can I declare a class variable as floating point in Moose? My (fictional) sample below produces errors for "Real", "Number" etc ... "Str" works but defeats the purpose .. searching/Google doesn't help, sinc...Learn More
    Perlfloating-pointmoose
  5. python 2.5: how to convert float to hex?

    I want to convert a float (the output of time.time()) in hex using python 2.4/2.5. I found tons of examples that convert hex to float, but I cannot find anything that allows me to do what the float.hex() of py...Learn More
    PythonHexfloating-point
  6. Is it possible to read Fortran formatted data in Python?

    I get output files from very old Fortran programs, which look like: 0.81667E+00 -0.12650E+01 -0.69389E-03 0.94381E+00 -0.11985E+01 -0.11502E+00 0.96064E+00 -0.11333E+01 -0.17616E+00 0.10202E+01 -0.12...Learn More
    PythonFormatFortranfloating-point
  7. Using iPhone/Objective C CGFloats: Is 0.1 okay, or should it be 0.1f?

    When using an iPhone Objective C method that accepts CGFloats, e.g. [UIColor colorWithRed:green:blue:], is it important to append a f to constant arguments to specifiy them explicitly as floats, e.g. should I a...Learn More
    Doublefloating-pointobjective-ccore-graphicscgfloat
  8. Extracting individual digits from a float

    I have been banging my head on this one all day. The C++ project I am currently working on has a requirement to display an editable value. The currently selected digit displays the incremented value above and...Learn More
    Extractfloating-pointc++digits
  9. Python rounding problem

    >>> num = 4.123456 >>> round(num, 3) # expecting 4.123 4.1230000000000002 I'm expecting 4.123 as a result, Am I wrong?...Learn More
    PythonMathfloating-point
  10. round() in Python doesn't seem to be rounding properly

    The documentation for the round() function states that you pass it a number, and the positions past the decimal to round. Thus it should do this: n = 5.59 round(n, 1) # 5.6 But, in actuality, good old floating...Learn More
    Pythonfloating-point
  11. Floating Point Modulo Problem

    I've stumbled onto a very strange bug. Read the comments in the code to see what the bug is exactly, but essentially a variable modulo 1 is returning 1 (but it doesn't equal 1!). I'm assuming there is a display...Learn More
    Pythonfloating-pointfloating-accuracy
  12. Generate "fuzzy" difference of two files in Python, with approximate comparison of floats

    I have an issue for comparing two files. Basically, what I want to do is a UNIX-like diff between two files, for example: $ diff -u left-file right-file However my two files contain floats; and because these ...Learn More
    Pythonfloating-pointfuzzy-comparisoninexact-arithmetic