Questions tagged [zero]

Zero is a unique number and along with 1 is one of the two binary numbers. Zero plays an important role in Mathematics and Computing. This Tag is for discussions of zero within various programming languages.

Zero is a unique number and along with 1 is one of the two binary numbers. Zero plays an important role in Mathematics and Computing. This Tag is for discussions of zero within various programming languages.

1060 questions
27
votes
5 answers

Add leading zeroes to awk variable

I have the following awk command within a "for" loop in bash: awk -v pdb="$pdb" 'BEGIN {file = 1; filename = pdb"_" file ".pdb"} /ENDMDL/ {getline; file ++; filename = pdb"_" file ".pdb"} {print $0 > filename}' < ${pdb}.pdb This reads a series…
mirix
  • 511
  • 1
  • 5
  • 13
26
votes
4 answers

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.
MattGrommes
  • 11,974
  • 9
  • 37
  • 40
26
votes
2 answers

/dev/zero or /dev/random - what is more secure and why?

Can anyone tell me why is /dev/random is preferred for security while wiping data from a hard drive?
skater_nex
  • 453
  • 1
  • 5
  • 11
25
votes
4 answers

Remove leading zeros in batch file

In my application, I get a number having leading zeros. I am trying to trim the leading zeros and get the actual number. I tried using /a switch which considers right side of the assignment as an arithmetic expression. So I tried: SET /a N =…
Mahesh
  • 34,573
  • 20
  • 89
  • 115
23
votes
2 answers

Padding a fixed number with leading zeros up to a fixed length

In Crystal Report using Visual Studio 2010, I am trying a to create a formula for the following scenario: x = any number (Fixed number of 8 digits, cant be less or greater) If Length of X is less than 8, pad the required amount of 0's in the front…
aMazing
  • 1,430
  • 4
  • 20
  • 43
22
votes
4 answers

Mysql AVG to ignore zero

I need to perform an avg on a column, but I know that most of the values in that column will be zero. Out of all possible rows, only two will probably have positive values. How can I tell mySQL to ignore the zeros and only average the actual values?
Oranges13
  • 1,084
  • 1
  • 10
  • 33
21
votes
5 answers

Why initialize HashSet<>(0) to zero?

I love a HashSet<>() and use this eagerly while initializing this with the default constructor: Set users = new HashSet<>(); Now, my automatic bean creator (JBoss tools) initializes this as: Set users = new HashSet<>(0); Why the…
Dimitri Dewaele
  • 10,311
  • 21
  • 80
  • 127
21
votes
7 answers

What is the idiomatic way to return either a struct or an error?

I have a function that returns either a Card, which is a struct type, or an error. The problem is, how can I return from the function when an error occurs ? nil is not valid for structs and I don't have a valid zero value for my Card type. func…
Fabien
  • 12,486
  • 9
  • 44
  • 62
20
votes
3 answers

Is null considered zero and undefined not a number on arithmetic expressions?

Is null evaluated to 0 and undefined to NaN on arithmetic expressions? According to some testing it seems so: > null + null 0 > 4 + null 4 > undefined + undefined NaN > 4 + undefined NaN Is it safe or correct to assume this? (a quote from a…
talles
  • 14,356
  • 8
  • 45
  • 58
19
votes
3 answers

C# Padding Amount With Zeros

I have an amount field which is a decimal in the database. I need to always display this amount with 10 numbers on the left of the decimal and two after. Example: Amount = 245.00 which should display as 0000000245.00 Additionally, the amount could…
Baxter
  • 5,633
  • 24
  • 69
  • 105
19
votes
3 answers

How to parse signed zero?

Is it possible to parse signed zero? I tried several approaches but no one gives the proper result: float test1 = Convert.ToSingle("-0.0"); float test2 = float.Parse("-0.0"); float test3; float.TryParse("-0.0", out test3); If I use the value…
mortal
  • 225
  • 2
  • 7
18
votes
3 answers

How to efficiently compare the sign of two floating-point values while handling negative zeros

Given two floating-point numbers, I'm looking for an efficient way to check if they have the same sign, given that if any of the two values is zero (+0.0 or -0.0), they should be considered to have the same sign. For instance, SameSign(1.0, 2.0)…
François Beaune
  • 4,270
  • 7
  • 41
  • 65
17
votes
4 answers

Comparing floating point numbers in C

I've got a double that prints as 0.000000 and I'm trying to compare it to 0.0f, unsuccessfully. Why is there a difference here? What's the most reliable way to determine if your double is zero?
nick_name
  • 1,353
  • 3
  • 24
  • 39
17
votes
7 answers

Windows font that clearly disambiguates the number ZERO from letter O

Our intranet web pages need to clearly disambiguate between the letter O and the number ZERO. Is there a screen+printer font that is installed on WindowsXP and Vista that does this either putting a dot inside zero or a slash through it? If there…
Tim
  • 8,669
  • 31
  • 105
  • 183
17
votes
1 answer

h:inputText which is bound to Integer property is submitting value 0 instead of null

We are using a h:inputText in a JSF page which is bound to an Integer property (and thus can accept null). When there is no value written in the h:inputText, the form is submitting a 0 instead of null. We are using Trinidad 1.2.2 and Tomcat 6.0.20…
Averroes
  • 4,168
  • 6
  • 50
  • 63
1 2
3
70 71