Search Results

Search found 296 results on 12 pages for 'markus larsson'.

Page 7/12 | < Previous Page | 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Is there a way to do 'correct' arithmetical rounding in .NET? / C#

    - by Markus
    I'm trying to round a number to it's first decimal place and, considering the different MidpointRounding options, that seems to work well. A problem arises though when that number has sunsequent decimal places that would arithmetically affect the rounding. An example: With 0.1, 0.11..0.19 and 0.141..0.44 it works: Math.Round(0.1, 1) == 0.1 Math.Round(0.11, 1) == 0.1 Math.Round(0.14, 1) == 0.1 Math.Round(0.15, 1) == 0.2 Math.Round(0.141, 1) == 0.1 But with 0.141..0.149 it always returns 0.1, although 0.146..0.149 should round to 0.2: Math.Round(0.145, 1, MidpointRounding.AwayFromZero) == 0.1 Math.Round(0.146, 1, MidpointRounding.AwayFromZero) == 0.1 Math.Round(0.146, 1, MidpointRounding.ToEven) == 0.1 Math.Round(0.146M, 1, MidpointRounding.ToEven) == 0.1M Math.Round(0.146M, 1, MidpointRounding.AwayFromZero) == 0.1M I tried to come up with a function that addresses this problem, and it works well for this case, but of course it glamorously fails if you try to round i.e. 0.144449 to it's first decimal digit (which should be 0.2, but results 0.1.) (That doesn't work with Math.Round() either.) private double round(double value, int digit) { // basically the old "add 0.5, then truncate to integer" trick double fix = 0.5D/( Math.Pow(10D, digit+1) )*( value = 0 ? 1D : -1D ); double fixedValue = value + fix; // 'truncate to integer' - shift left, round, shift right return Math.Round(fixedValue * Math.Pow(10D, digit)) / Math.Pow(10D, digit); } I assume a solution would be to enumerate all digits, find the first value larger than 4 and then round up, or else round down. Problem 1: That seems idiotic, Problem 2: I have no idea how to enumerate the digits without a gazillion of multiplications and subtractios. Long story short: What is the best way to do that?

    Read the article

  • Including uncovered files in Devel::Cover reports

    - by Markus
    I have a project setup like this: bin/fizzbuzz-game.pl lib/FizzBuzz.pm test/TestFizzBuzz.pm test/TestFizzBuzz.t When I run coverage on this, using perl -MDevel::Cover=-db,/tmp/cover_db test/*.t ... I get the following output: ----------------------------------- ------ ------ ------ ------ ------ ------ File stmt bran cond sub time total ----------------------------------- ------ ------ ------ ------ ------ ------ lib/FizzBuzz.pm 100.0 100.0 n/a 100.0 1.4 100.0 test/TestFizzBuzz.pm 100.0 n/a n/a 100.0 97.9 100.0 test/TestFizzBuzz.t 100.0 n/a n/a 100.0 0.7 100.0 Total 100.0 100.0 n/a 100.0 100.0 100.0 ----------------------------------- ------ ------ ------ ------ ------ ------ That is: the totally-uncovered file bin/fizzbuzz-game.pl is not included in the results. How do I fix this?

    Read the article

  • Ruby - Possible to pass a block as a param as an actual block to another function?

    - by Markus O'Reilly
    This is what I'm trying to do: def call_block(in_class = "String", &block) instance = eval("#{in_class}.new") puts "instance class: #{instance.class}" instance.instance_eval{ block.call } end # --- TEST EXAMPLE --- # This outputs "class: String" every time "sdlkfj".instance_eval { puts "class: #{self.class}" } # This will only output "class: Object" every time # I'm trying to get this to output "class: String" though call_block("String") { puts "class: #{self.class}" } On the line where it says "instance.instance_eval{ block.call }", I'm trying to find another way to make the new instance variable run instance eval on the block. The only way I can think of to get it to do that is to pass instance_eval the original block, not as a variable or anything, but as a real block like in the test example. Any tips?

    Read the article

  • XCode: How to adress dynamic Variables?

    - by Markus S.
    I want to do something like that: for (v=1;v=150;v++) { for (h=1; h=250;v++) { tile_0%i_0%i.image = [UIImage imageWithData:tmp_content_of_tile]; //1st %i = v; 2nd %i = h } } In the %i should be inserted the current value of "v" or "h"? Is it possible? How is it called? Greets!

    Read the article

  • Concatenating rows from different tables into one field

    - by Markus
    Hi! In a project using a MSSQL 2005 Database we are required to log all data manipulating actions in a logging table. One field in that table is supposed to contain the row before it was changed. We have a lot of tables so I was trying to write a stored procedure that would gather up all the fields in one row of a table that was given to it, concatenate them somehow and then write a new log entry with that information. I already tried using FOR XML PATH and it worked, but the client doesn't like the XML notation, they want a csv field. Here's what I had with FOR XML PATH: DECLARE @foo varchar(max); SET @foo = (SELECT * FROM table WHERE id = 5775 FOR XML PATH('')); The values for "table", "id" and the actual id (here: 5775) would later be passed in via the call to the stored procedure. Is there any way to do this without getting XML notation and without knowing in advance which fields are going to be returned by the SELECT statement?

    Read the article

  • ImpersonateLoggedOnUser and starting a new process that uses ocx fails.

    - by markus
    I write a c++ windows application (A), that uses LogonUser, LoadUserProfile and ImpersonateLoggedOnUser to gain the rights of another user (Y). Meaning the A starts using the user that is logged on on the workstation (X). If the user wants to elevate his rights he can just press a button and logon as another user without having to log himself out of windows and back in. The situation now is (according to the return values of the functions): LogonUser works, LoadUserProfile works and ImpersonateLoggedOnUser works as well. After the impersonation I start another process. This process is an application (B) that needs an OCX control. This fails and the application tells me that the .oxc file is not properly installed. The thing is, if I start B directly as the user that is logged on to the machine (X), it works. If I start B directly as the user (Y) to which I want to elevate my rights using A, it works. If I am logged in as (X) and choose "run as" (Y) in the explorer, it works! Do you know which steps I need to do to do the same as the "run as" dialog from windows?

    Read the article

  • Problem with Deploying a ASP.NET MVC Project on a IIS 7.0. BadImageFormatException

    - by Markus
    Hello world, I am stuck with my web application. As known from the title its a ASP.NET MVC(1,0) application so i do the only 2 things that a needed do deploy a application like this. I made a build an copied it to the IIS Folder. In the IDE (VS2008) all works fine :(. This worked a long time. But know i get a error for my included dll of a other project. (I have a German version so the Error is Translated from google sry for that) BadImageFormatException: File or assembly 'DataService.WebInterface.BusinessLogic "or one of its dependencies was not found. An attempt was made to load a file with an incorrect format.] System.Reflection.Assembly._nLoad (AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark & stackMark, throwOnFileNotFound Boolean, Boolean forIntrospection) +0 System.Reflection.Assembly.InternalLoad (AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark & stackMark, Boolean forIntrospection) +416 System.Reflection.Assembly.InternalLoad (String String assemblyName, Evidence assemblySecurity, StackCrawlMark & stackMark, Boolean forIntrospection) +166 System.Reflection.Assembly.Load (String string assemblyName) +35 System.Web.Configuration.CompilationSection.LoadAssemblyHelper (String assemblyName, Boolean starDirective) +190 What does that mean? Is the File corrupted or do i have to change the web.config? Thank your for your support!

    Read the article

  • Timer in windows service

    - by Markus
    Hi. I have an issue with System.Threading.Timer. I am scheduling some actions using a time in a windows service. The timer starts executing the callback after a specified dueTime period. The windows service starts up after reboot automatically. However, I have observed a strange thing after a system reboot- the callback method starts executing itself 3 or 4 minutes before the specified period. What might be the reason for such behavior? Here is the sample code: TimeSpan timeToWait = this.StartTime - DateTime.Now; Int64 msToSleep = (Int64)Math.Round(timeToWait.TotalMilliseconds); _timer = new Timer(callback_method, null, msToSleep, MinutesScheduledInterval * 60000); where _timer is a member variable, StartTime - the time when the timer should first fire.

    Read the article

  • Why does GetClusterShape return null when the cluster specification was retrieved through the GetClu

    - by Markus Olsson
    Suppose I have a virtual earth shape layer called shapeLayer1 (my creative energy is apparently at an alltime low). When i call the GetClusteredShapes method I get an array of VEClusterSpecification objects that represent each and every one of my currently visible clusters; no problem there. But when I call the GetClusterShape() method it returns null... null! Why on earth would it do that? I used firebug to confirm that the private variable of the VEClusterSpecification that's supposed to hold a reference to the shape is indeed null so it's not the method that's causing the problem. Some have suggested that this is actually documented behavior Returns null if a VEClusterSpecification object was returned from the VEShapeLayer.GetClusteredShapes Method But looking at the current MSDN documentation for the VEShape class it says: Returns if a VEClusterSpecification object was returned from the VEShapeLayer.GetClusteredShapes Method Is this a bug or a feature? Is there any known workarounds or (if it is a bug) some plan on when they are going to fix it?

    Read the article

  • Sorting a GridView

    - by Markus
    Hi, I have a question regarding GridView windows forms control. As a datasource, I am using a DataTable object. When the grid view is sorted, the DataTable's row indices are not sorted. In this way, when accessing the DataTable using indices from GridView, I get the unexpected rows. How can this situation be handled?

    Read the article

  • Ajaxrequest with Wicket but multiple possilbe model values

    - by Markus Maria Miedaner
    Hi, I'm new to wicket and stuck with the following problem: I have a table with 5 rows. Each row contains 7 cells. Each cell has a unique value. Once a cell is clicked, its unqiue value should be posted to the server. I would like to register only one ajaxfallbacklink (or similar) on the table and adjust the value of the model to the unique value of cell that has been clicked. Any ideas?

    Read the article

  • Ruby - How to remove a setter on an object

    - by Markus Orrelly
    Given a class like this: class B class << self attr_accessor :var end end Suppose I can't modify the original source code of class B. How might I go about removing the setter on the class variable var? I've tried using something like B.send("unset_method", "var="), but that doesn't work (nor does remove_method, or overwriting that method with a var= method that doesn't do anything). Any ideas?

    Read the article

  • Bind WCF webservice to specific network interface / IP

    - by Markus
    On a machine with multiple network cards I need to bind a WCF webservice to a specific network interface. It seems that the default is to bind on all network interfaces. The machine has two network adapters with the IPs 192.168.0.10 and 192.168.0.11. I have an Apache running that binds on 192.168.0.10:80 and need to run the webservice on 192.168.0.11:80. (Due to external circumstances I cannot choose another port.) I tried the following: string endpoint = "http://192.168.0.11:80/SOAP"; ServiceHost = new ServiceHost(typeof(TService), new Uri(endpoint)); ServiceHost.AddServiceEndpoint(typeof(TContract), Binding, ""); // or: ServiceHost.AddServiceEndpoint(typeof(TContract), Binding, endpoint); But it doesn't work; netstat -ano -p tcp always shows the webservice listening on 0.0.0.0:80, which is all interfaces (if I got that correct). When I start Apache first, it correctly binds to the other interface, which in turn prevents the WCF service to bind to "all". Any ideas?

    Read the article

  • Parse URLs of major video streaming sites and generate appropriate code for embedding.

    - by Markus Lux
    Posting a video on tumblr.com allows you to just paste the URL of the video on youtube, vimeo, whatever and tumblr automatically does the embedding for you. I assume that this would be nothing more than a mapping between an URL-regex and the belonging HTML construct for embedding the video. Or it is just parsing the response of the URL and getting the construct from there. Is there already any utility, preferably in Java, for doing this? If not, how would you do it?

    Read the article

  • Problem with referencing CSS and Javascript files relatively

    - by Markus
    I have an IIS web site. This web site contains other web sites so the structure is like this. \ MainWebSite\ App1\ App2\ All sites are Asp.net MVC Webapplications. In the MasterPage of App1, I reference the script files like this: <script type="text/javascript" src="../../Scripts/jquery-ui-1.8.custom.min.js"> </script> The Problem is that he now tries to find the File at http:\server\MainWebSite\Scripts.... how can i work around that? Should I put all my Scripts and CSS files into the root directory, is that a preferred solution?

    Read the article

  • TSQL ID generation

    - by Markus
    Hi. I have a question regarding locking in TSQL. Suppose I have a the following table: A(int id, varchar name), where id is the primary key, but is NOT an identity column. I want to use the following pseudocode to insert a value into this table: lock (A) uniqueID = GenerateUniqueID() insert into A values (uniqueID, somename) unlock(A) How can this be accomplished in terms of TSQL? The computation of the next id should be done with the table A locked in order to avoid other sessions to do the same operation at the same time and get the same id.

    Read the article

  • No Debug information of an iPhone app

    - by Markus Pilman
    Hi all, I wrote an iPhone app which uses a third party library. I crosscompiled this library successfully and everything works smoothly. But when I want to debug the application, it would make sense to also be able to debug the library. So I compiled also the external library with debuging information (usign the gcc option -ggdb). But when I want to debug it, I get the correct symbol names, but the positions are always wrong/extremly wierd (locale_facets.tcc:2505 or iostream:76). For example a stack trace could look like this: #0 0x000045e8 in zorba::serialization::SerializeBaseClass::SerializeBaseClass () at iostream:76 #1 0x0001d990 in zorba::RCObject::RCObject () at iostream:76 #2 0x00025187 in zorba::xqpStringStore::xqpStringStore () at iostream:76 #3 0x000719e4 in zorba::String::String () at locale_facets.tcc:2505 #4 0x00030513 in iphone::iLabelModule::getURI (this=0x533f710) at /Users/sausalito/eth/izorba/sandbox/ilabel.cpp:19 #5 0x00356766 in zorba::static_context::bind_external_module () at locale_facets.tcc:2505 #6 0x0006139d in zorba::StaticContextImpl::registerModule () at locale_facets.tcc:2505 #7 0x000333e5 in -[ZorbaCaller init] (self=0x53405c0, _cmd=0x95583398) at /Users/sausalito/eth/izorba/sandbox/ZorbaCaller.mm:61 #8 0x00033180 in +[ZorbaCaller instance] (self=0x11dc2bc, _cmd=0x93679591) at /Users/sausalito/eth/izorba/sandbox/ZorbaCaller.mm:37 #9 0x0003d998 in -[testOne execute:] (self=0x530d560, _cmd=0x9366b126, sender=0x5121da0) at /Users/sausalito/eth/izorba/sandbox/generator/testOne.mm:13 #10 0x01a21405 in -[UIApplication sendAction:to:from:forEvent:] () #11 0x01a84b4e in -[UIControl sendAction:to:forEvent:] () #12 0x01a86d6f in -[UIControl(Internal) _sendActionsForEvents:withEvent:] () #13 0x01a85abb in -[UIControl touchesEnded:withEvent:] () #14 0x01a3addf in -[UIWindow _sendTouchesForEvent:] () #15 0x01a247c8 in -[UIApplication sendEvent:] () #16 0x01a2b061 in _UIApplicationHandleEvent () #17 0x03b6fd59 in PurpleEventCallback () #18 0x034a8b80 in CFRunLoopRunSpecific () #19 0x034a7c48 in CFRunLoopRunInMode () #20 0x03b6e615 in GSEventRunModal () #21 0x03b6e6da in GSEventRun () #22 0x01a2bfaf in UIApplicationMain () #23 0x0002dd7e in main (argc=1, argv=0xbffff044) at /Users/sausalito/eth/izorba/sandbox/main.m:16 Does anybody have an idea, where these wrong locations come from?

    Read the article

  • OpenAL device, buffer and context relationship

    - by Markus
    I'm trying to create an object oriented model to wrap OpenAL and have a little problem understanding the devices, buffers and contexts. From what I can see in the Programmer's Guide, there are multiple devices, each of which can have multiple contexts as well as multiple buffers. Each context has a listener, and the alListener*() functions all operate on the listener of the active context. (Meaning that I have to make another context active first if I wanted to change it's listener, if I got that right.) So far, so good. What irritates me though is that I need to pass a device to the alcCreateContext() function, but none to alGenBuffers(). How does this work then? When I open multiple devices, on which device are the buffers created? Are the buffers shared between all devices? What happens to the buffers if I close all open devices? (Or is there something I missed?)

    Read the article

  • PEAR:DB connection parameters

    - by Markus Ossi
    I just finished my first PHP site and now I have a security-related question. I used PEAR:DB for the database connection and made a separate parameter file for it. How should I hide this parameter file? I found a guide (http://www.kitebird.com/articles/peardb.html) that says: Another way to specify connection parameters is to put them in a separate file that you reference from your main script. ... It also enables you to move the parameter file outside of the web server's document tree, which prevents its contents from being displayed literally if the server becomes misconfigured and starts serving PHP scripts as plain text. I have now put my file in a directory like this /include/db_parameters.inc However, if I go to this URL, the web server shows me the contents of the file including my database username and password. From what I've understood, I should protect this file so, that even though PHP would be served as text, nobody could read this. What does outside of web server's document tree mean here? Put the PHP file out of public_html directory altogether deeper into the server file system? Some CHMOD?

    Read the article

< Previous Page | 3 4 5 6 7 8 9 10 11 12  | Next Page >