zero

Is there a difference between BigDecimal("0") and BigDecimal.ZERO?

Either for comparisons or initialization of a new variable, does it make a difference which one of these you use? I know that BigDecimal.ZERO is a 1.5 feature, so that's a concern, but assuming I'm using 1.5 does it matter? Thanks. ...

Array of zero length

I am working on refactoring some old code and have found few structs containing zero length arrays (below). Warnings depressed by pragma, of course, but I've failed to create by "new" structures containing such structures (error 2233). Array 'byData' used as pointer, but why not to use pointer instead? or array of length 1? And of course...

C#.NET: Is it safe to check floating point values for equality to 0?

I know you can't rely on equality between double or decimal type values normally, but I'm wondering if 0 is a special case. While I can understand imprecisions between 0.00000000000001 and 0.00000000000002, 0 itself seems pretty hard to mess up since it's just nothing. If you're imprecise on nothing, it's not nothing anymore. But I do...

Truncate leading zeros of a string in Javascript

Hi all, I have a textbox in Javascript. When I enter '0000.00' in the textbox, I want to know how to convert that to only having one leading zero, such as '0.00'. Please anybody help me in this regard. Thanks in advance.. raja. ...

nullable types: best way to check for null or zero in c#

i'm working on a project where i find i'm checking for the following in many, many places: if(item.Rate == 0 || item.Rate == null) { } more as a curiousity than anything, what's the best way to check for both cases? I've added a helper method which is: public static bool nz(object obj) { var parsedInt = 0; var parsed = int.Try...

What would you use to zero pad a number in Flex/AS3?

Duplicate of this one. What would you use to pad zeroes to the left of a number in Flex/AS3? Is there an equivalent to printf or NumberFormat that does this? I'm looking for the nicest implementation of this or something similar: public function zeroPad(number:int, width:int):String { // number = 46, width = 4 would return "0046"...

Under what circumstances will Active Record fail to enforce optimistic locking?

I watched in horror this morning as a script, running on two different machines, happily loaded, updated, and saved. I'm running ruby 1.8.6, AR 2.2.2. I started playing with some test cases and found reduced it to a minimal reproduction case: irb(main):059:0> first = Job.find :first => #<Job id: 323, lock: 8, worker_host: "second"> i...

How to store the integer value "0" in a .bin file? (C++)

EDIT: Apparently, the problem is in the read function: I checked the data in a hex editer 02 00 00 00 01 00 00 00 00 00 00 00 So the zero is being stored as zero, just not read as zero. Because when I use my normal store-in-bin file function: int a = 0; file.write(reinterpret_cast<char*>(&a), sizeof(a)); It stores 0 as the char ve...

How to get a -0 result in floating point calculations and distinguish it from +0 in C#?

The MSDN documentation mentions that double type includes negative zero. However, both -1.0 / double.PositiveInfinity and -double.Epsilon / 2 appear to return normal 0 (and compare equal to it). How can I get -0? ...

T-SQL, zero sum for no match on join

Hi All I have two tables, one with all my Branches, and one with all my sales. The sales table also contains a Sales Rep ID, a Branch ID, a month and a year. I need a query that will return the sum of a specific rep's sales for a year, grouped by branch and month, and the query must return 0 if there has been no sales in a branch for ...

SQL Server 2000 distinguishes between decimal zero 0.00 and -.00 while ADO.NET does not

We're using SQL Server Standard Edition 8.00.760 (SP3) on a Small Business Server 2003 platform. While tracking down an inexplainable System.Data.DBConcurrencyException for a Strongly Typed DataSet, I discovered the following problem: Given is this table: CREATE TABLE [dbo].[Auszahlung]( [auszahlungid] [int] IDENTITY(1,1) NOT NULL,...

Windows Mobile GetDeviceCaps always returns zero

Is there a precondition to calling GetDeviceCaps? I'm trying to discover (at run-time) whether the native screen resolution for a Windows Mobile device is QGVA or VGA. The following return values are all zero in OnInitDialog(): CDC* dc = GetDC(); int horzRes = GetDeviceCaps( HDC(dc), HORZRES ); int vertRes = GetDeviceCaps( HDC(dc), VE...

Verifying equivalence of a secret

Alice & Bob are both secret quadruple agents who could be working for the US, Russia or China. They want to come up with a scheme that would: a) if they are both working for the same side, prove this to each other so they can talk freely. b) if they are working for different sides, not expose any additional information about which side...

Pad python floats

I want to pad some percentage values so that there are always 3 units before the decimal place. With ints I could use '%03d' - is there an equivalent for floats? '%.3f' works for after the decimal place but '%03f' does nothing. ...

zerofill a interger php

Hay, how would i go about 'zero filling' an integer? ie 1 becomes 0001 40 becomes 0040 174 becomes 0174 Thanks ...

c++ how to add a zero bits byte or null to a string

Hi I am doing a simple client implementation of TFTP. Here i need to send read request in following format /* send request 2 bytes string 1 byte string 1 byte ------------------------------------------------------ RRQ/ | 01/02 | Filename | 0 | Mode | 0 | WRQ -----------------------------------------...

Objective C - Are SystemSoundID's (typedef'd UInt32) automatically assigned 0?

- (void)playAlarmSound:(NSTimer *)theTimer { static SystemSoundID soundID/* = 0 */; // ? if (!soundID) { soundID = [Utilities createSystemSoundIDFromFile:@"beep" ofType:@"caf"]; } ... } Is SystemSoundID (which is a UInt32) automatically assigned 0? or should I explicitly assign it? I have to do it this way and t...

Mysql count return Zero if no record found

I have a two tables for ex: cities - id_city, city_name properties - id_property, id_city, property_name I want to display cities.city_name and next to it [properties.count(id_city)] How do I make a query that still return ZERO if no records founds istead on NULL so I get results like London [123] New York [0] Berlin [11] and NEW...

I need a VB code to remove the zero values(Data values) on varous pivot charts

I have about 12 pivot charts and I need help to creat a VB code that will delete only the zero values(Data values) on all the Pivot chart. These are Stacked charts for 3 metrics. eg : Ontime, late and not notified. I need only the values which are not "0" to reflect on the pivot charts.Please help. ...

show decimal or double with zeros

hi i get price values from DB. now whenever the price is perhaps 5, I want to show 5.00 if its 4.3 it should be 4.30. how to convert that? thanks ...