How do I round a decimal value to 2 decimal places (for output on a page)

How do I round a decimal value to 2 decimal places (for output on a page)

When displaying the value of a decimal currently with .ToString(), it's accurate to like 15 decimal places, and since I'm using it to represent dollars and cents, I only want the output to be 2 decimal places. Do I use a variation of .ToStr

How do I check if an element is hidden in jQuery?

How do I check if an element is hidden in jQuery?

It is possible to toggle the visibility of an element, using the functions .hide(), .show() or .toggle().How would you test if an element is visible or hidden? 1:Since the question refers to a single element, this code might be more suit

“static const” vs “#define” vs “enum”

“static const” vs “#define” vs “enum”

Which one is better to use among the below statements in C?static const int var = 5;or #define var 5orenum { var = 5 }; 1:Generally speaking:static constBecause it respects scope and is type-safe.The only caveat I could see: if you want

What are forward declarations in C++?

What are forward declarations in C++?

At: http://www.learncpp.com/cpp-tutorial/19-header-files/The following is mentioned:add.cpp:int add(int x, int y){ return x + y;}main.cpp:#include int add(int x, int y); // forward declaration using function prototypeint main()

Understanding PrimeFaces process/update and JSF f:ajax execute/render attributes

Understanding PrimeFaces process/update and JSF f:ajax execute/render attributes

What exactly are process and update in PrimeFaces p:commandXxx components and execute and render in f:ajax tag?Which works at the time of validation? What does update attribute do rather than updating value to component from back end? Do pr

How does the 'binding' attribute work in JSF? When and how should it be used?

How does the 'binding' attribute work in JSF? When and how should it be used?

There are lot of materials out there differentiating value attribute and binding attribute in JSF.I'm interested in how both approaches differ from each other. Given:public class User { private String name; private UICommand link;

Why aren't variable-length arrays part of the C++ standard?

Why aren't variable-length arrays part of the C++ standard?

I haven't used C very much in the last few years. When I read this question today I came across some C syntax which I wasn't familiar with.Apparently in C99 the following syntax is valid:void foo(int n) { int values[n]; //Declare a varia

Using i and j as variables in Matlab

Using i and j as variables in Matlab

i and j are very popular variable names (see e.g., this question and this one). For example, in loops:for i=1:10, % do something...endAs indices into matrix:mat( i, j ) = 4;Why shouldn't they be used as variable names in Matlab? 1:Be

How does atoi() function in C++ work?

How does atoi() function in C++ work?

So...I know that the atoi function in the C++ standard library is supposed to convert a string into an integer...how does it work?...(I'm trying to learn stuff and I was just wondering)...if you could show me the code from it or make your o

Updating multiple rows Linq vs SQL

Updating multiple rows Linq vs SQL

Some time ago I wrote a piece of code to update multiple rows in a database table. The code was like thisvar db = new MyDataContext();db.Execute("UPDATE Details SET IsActive = 0 WHERE MasterId = 1");Then the other day when I got the latest

Why should objects in Redux be immutable?

Why should objects in Redux be immutable?

Why should objects in Redux be immutable?I know that some frameworks such as Angular2 will use onPush and can take advantage of immutability to compare states of views for faster rendering, but I am wondering if there are other reasons as R

Why does a perfect forwarding function have to be templated?

Why does a perfect forwarding function have to be templated?

Why is the following code valid:templatevoid foo(T1 &&arg) { bar(std::forward(arg)); }std::string str = "Hello World";foo(str); // Valid even though str is an lvaluefoo(std::string("Hello World")); // Valid because literal is rvalueBut not:

Why is php5isapi.dll missing after installing PHP for Windows?

Why is php5isapi.dll missing after installing PHP for Windows?

It's been a while since I've installed PHP for Windows, but every guide I've seen online tells me to set IIS to recognize .PHP files with php5isapi.dll. However, I can't seem to find php5isapi.dll anywhere after installing PHP 5.3.0 and PH

Inner left-floating div's do not expand the container div vertically

Inner left-floating div's do not expand the container div vertically

I have a container div with the following attributes:#cat_container{margin:0;padding:5px;border:1px solid red;min-height:200px;}Inside there are multiple left floating div's. The problem is that they don't force the containing div to expand

C# Optional Parameters or Method Overload? [duplicate]

C# Optional Parameters or Method Overload? [duplicate]

This question already has an answer here: method overloading vs optional parameter in C# 4.0 [duplicate] 11 answers Since C# added optional parameters

Bootstrap 3.1 visible-xs and visible-sm not working together

Bootstrap 3.1 visible-xs and visible-sm not working together

I have a div that I want to show on sm and xs devices, it looks like this: Item 1 Item 2 Item 3My bootstrap is loading from cdn without any customization.This is supposed to show this div on xs and sm as stated on classes but the resu

Executing a certain action for all elements in an Enumerable

Executing a certain action for all elements in an Enumerable

I have an Enumerable and am looking for a method that allows me to execute an action for each element, kind of like Select but then for side-effects. Something like:string[] Names = ...;Names.each(s => Console.Writeline(s));or Names.each(s

how to detect a mobile phone in a web application [closed]

how to detect a mobile phone in a web application [closed]

If a web application, how can you figure out the visitor is viewing from a mobile phone?is it also possible figure out the make/model like blackberry versus iphone? 1:You could check their User-Agent string. 2:Scott Hanselman did a po

How to access Jersey resource secured by @RolesAllowed

How to access Jersey resource secured by @RolesAllowed

We were testing a REST webservice developed in jersey through postman rest client. It is a POST method and is annotated with @RolesAllowed. The full annotation the method is as follows:@[email protected]("/configuration")@RolesAllowed("admin")@Prod

Do commercial (paid) iPhone apps have to pay a license to Google for Maps? [closed]

Do commercial (paid) iPhone apps have to pay a license to Google for Maps? [closed]

I know that happens with commercial websites so I was wondering if commercial iPhone apps that use the MapKit (especially those that generate a lot of traffic) need to get any sort of license from Google Maps as well.My best guess would be

Vista Schedule Task From Setup

Vista Schedule Task From Setup

I'm deploying a C# application using the Setup Wizard project in Visual Studio 2008. What is the simplest way for me to have Windows schedule my application to run at regular intervals (e.g. every 8 hours)? I prefer if this scheduling wou

Android IRC Office Hours Question About Android Bluetooth RSSI

Android IRC Office Hours Question About Android Bluetooth RSSI

I have a question about bluetooth RSSI functionality on the Android (either 2.0 or 2.1):It's easy enough to get the RSSI value when a bluetooth connection is created, but how can you repeatedly get the RSSI value of a connection that is alr

bit shift operation does not return expected result

bit shift operation does not return expected result

Why does Java return -2147483648 when I bit shift 1 ?The expected result is 9 223 372 036 854 775 808, tested with Wolfram Alpha and my calculator..I tested: System.out.print((long)(1 1:There's an important thing to note about the li

XNA 3d physics engine [closed]

XNA 3d physics engine [closed]

I am looking for a 3D physics engine for XNA. I heard of some options, but what I need is:free for commercial purposes (preferable open-source)support for rigid body dynamicssupport for per-polygon collision (this is very important)managed

How to create Kotlin DSL - DSL syntax Kotlin

How to create Kotlin DSL - DSL syntax Kotlin

As with anko you can write callback functions like this: alert { title = "" message = "" yesButton { toast("Yes") } noButton { toast("No") }}How can I create a nested functions like that? I tried creating it