unexpected

C# float bug? 0.1 - 0.1 = 1.490116E-08

What's going on?! Subtraction works fine until I get to 0.1 - 0.1. I'm in visual c# 2008 using the nonoba.com API. Console.WriteLine("hit! " + Users[targetNum].character.health + " : " + player.character.profile.attackPower); Users[targetNum].character.health -= player.character.profile.attackPower; Console.WriteLine("health! " + User...

Unexpected result when using Enum.Parse()

class Program { static void Main(string[] args) { String value = "Two"; Type enumType = typeof(Numbers); Numbers number = (Numbers)Enum.Parse(enumType, value); Console.WriteLine(Enum.Parse(enumType, value)); } public enum Numbers : int { One, Two, Three, ...

What do $undefined and $end refer to in Ruby?

I used a backslash to continue a Ruby statement on the next line. print abc \ + def I added a space after the backslash, because I like to blow things up, and, sure enough, I got an error: unexpected $undefined, expecting $end I assume $undefined is a global variable that means anything the compiler sees that it doesn't recognize -...

Print methods not called when running, called when debugging

Hi, I created a class with four methods. I inserted print statements into them, so I could see if they work properly. There is no problem with the first three. But when I call the fourth method nothing prints out. Strangely when I initiate debugger and move through the method step by step, the statements are called(and output printed). ...

Why does the code execution never enter the catch block (java)?

I am trying to throw a (custom) ImportException from the method importUsers in class UserHelper. I can see in the debugger that the throw clause is executed, but the method, from which the importUsers method is called, never catches the exception. Here is the method, where the exception is thrown: public static AccessorValidator impor...

Why is ConsoleTraceListener not writing to a Console?

Quite often I run into items in the .NET framework that have little or no code examples on how to use the features. On other occasions, there are plenty of examples, but none of them seem to work as prescribed. Case in point: The System.Diagnostics.ConsoleTraceListener class. From everything I've read and every code example I've seen, ...

Extra "_" parameter in POST request using Chrome.

When I use Google Chrome to make an AJAX POST request I get extra empty parameter "_" on server-side. Here's some background information: Web-server: Python Paste Back-end: Python 2.6/Pylons Browser: Google Chrome 3.0.195.1 JavaScript Library: Prototype 1.6.1 RC3 For example simple: >>print sorted(request.POST.keys()) ['_','my_para...

jQuery show "loading" during slow operation

I'm trying to show a small loading image during a slow operation with jQuery and can't get it right. It's a BIG table with thousands of rows. When I check the "mostrarArticulosDeReferencia" checkbox it removes the "hidden" class from these rows. This operation takes a couple of seconds and I want to give some feedback. "loading" is a di...

Arrays.binarySearch doesnt work like it should

I have string array [1, 2, 3] and i search for all of those numbers using Arrays.binarySearch, it find 1 and 2, but with 3 it returns -1. any idea why it works that way? what is better alternative to always working search in array/collection? ...

Ruby Range Unexpected Behavior

Can anyone shed some insight onto why the following happens? irb(main):001:0> r = '1'..'30' => "1".."30" irb(main):002:0> r.each do |i| irb(main):003:1* puts "#{i} : #{r.include?(i)}" irb(main):004:1> end 1 : true 2 : true 3 : true 4 : false 5 : false 6 : false 7 : false 8 : false 9 : false 10 : true ... (snip.. the String-numbers here ...

Unexpected array behavior

The following modify method somehow modifies the whole @x array instead of just simply generating another element to be pushed later. How come? def modify i, s t = @x[-1] t[i] = t[i] + s t end @x = [ [10, 12] ] @x << modify(0, 1) puts @x Edited The following code have done the trick. Still I wonder if its possible to get rid o...

JavaScript IE appendChild() - Unexpected call to method or property access

I have been having this problem in IE. I have two divs which I use to drag selected elements from one to another. Lets say I have a child element (also a div) in div1 and some child elements in div2. I call the div2.appendChild() method on child element of div1. It removes the child from div1 and appends it to div2. If I then try to appe...

Odd strpos behavior

This is my code: <?php $url = "http://www.uhasselt.be/collegeroosters/2009_2010_298_5_10.html"; $headers = get_headers($url, 1); print_r($headers); $contloc = $headers["Content-Location"]; echo "Content-Location: " . $contloc . "\n"; $soft404test = strpos($contloc, "http://www.uhasselt.be/404b.htm") ? true : false; var_dump($soft404test...

os.kill not raising an OSError, however I do not see the given pid running

On my ubuntu server I run the following command: python -c 'import os; os.kill(5555, 0)' This is done so that I can see if pid 5555 is running. From my understanding this should raise an OSError if the pid is not running. This is not raising an OSError for me which means it should be a running process. However when I run: ps aux |...

PyQt4 QSpinBox.selectAll() not working as expected.

Python 2.5.4 PyQt4 I sub-classed a QDoubleSpinBox to emit a signal on a focusIn event: #Custom widgets for DPL GUI from PyQt4.QtCore import * from PyQt4.QtGui import * class DPLDoubleSpinBox(QDoubleSpinBox): __pyqtSignals__ = ("valueChanged(double)", "focusIn()") def __init__(self, *args): QDoubleSpinBox.__init__...

Why Unexpected Indent?

Why does this happen? def LoadPackageList(): try: #Attempts to load package list... Adds each neccessary attribute into array print("Loading Package List... please wait") packages = [] packagelisturl = os.getcwd() + "packages.list" dom = minidom.parse(urllib.urlopen(packagelisturl)) tr...

cmd: unexpected error with @pause and path>txt

Hello, I am coding a batch file. Here is a sample: if exist rootsys.txt del rootsys.txt if %lang%==1 ( if %bit%==32 echo C:\Program Files\path\to\the dir>rootsys.txt if %bit%==64 echo C:\Program Files(x86)\path\to\the dir>rootsys.txt goto :waset ) This goes on for six times (so if %lang%==2 etc... to if %lang%==6.) So, what it does,...

JUnit Easymock Unexpected method call

Hi, I'm trying to setup a test in JUnit w/ EasyMock and I'm running into a small issue that I can't seem to wrap my head around. I was hoping someone here could help. Here is a simplified version of the method I'm trying to test: public void myMethod() { //Some code executing here Obj myObj = this.service.getObj(param); i...

Program unexpectedly quits for unknown reason (C++)

For some reason, whenever I run this program it exits at permute(permutater, length, lenth); . This doesn't happen whenever I comment out the line and the function doesn't even run. Any help? ...

Ruby: counters, counting and incrementing

Hi, If you have seen my previous questions, you'd already know I am a big nuby when it comes to Ruby. So, I discovered this website which is intended for C programming, but I thought whatever one can do in C, must be possible in Ruby (and more readable too). The challenge is to print out a bunch of numbers. I discovered this nifty met...