Questions tagged [isinteger]

isinteger is a MATLAB built-in function

isinteger(A) returns true if the array A is an integer type and false otherwise.

Ref. isinteger

24 questions
10
votes
3 answers

PHP is_int is not performing as expected

I have a page (index.php) that takes a GET variable from the URL and checks it for security purposes. This GET variable should only be an integer. I am using the following code to check this, but in all instances, integer or not, I get the…
kirby
  • 3,981
  • 14
  • 41
  • 54
8
votes
3 answers

Number.isInteger(x) which is created can not work in IE

Number.prototype.isInteger = Number.prototype.isInteger || function(x) { return (x ^ 0) === x; } console.log(Number.isInteger(1)); will throw error in IE10 browser
huangxbd1990
  • 229
  • 2
  • 4
  • 10
5
votes
10 answers

PHP check if is integer

I have the following calculation: $this->count = float(44.28) $multiple = float(0.36) $calc = $this->count / $multiple; $calc = 44.28 / 0.36 = 123 Now I want to check if my variable $calc is integer (has decimals) or not. I tried doing if(is_int())…
Joachim Vanthuyne
  • 355
  • 1
  • 4
  • 14
4
votes
5 answers

Check string for integer

I want to validate a input field. The user should type in a phone number with minimum length of 10 digits. So I need to check for illegal chars. It would be nice just to check wheather the input is an integer or not. I came up with this but it does…
DarkLeafyGreen
  • 69,338
  • 131
  • 383
  • 601
2
votes
4 answers

unable to determine if a string is currently an integer or not

The following funciton drove me nuts. How on earth 100x could be equal to 100 and then 100x is reported as an integer? For the life of me, I cannot figure it out. You can copy and paste the whole thing and see it for yourself. I'm missing a simple…
Average Joe
  • 4,521
  • 9
  • 53
  • 81
2
votes
1 answer

Python 2 is_integer not returning properly

from fractions import Fraction counter = 0; a = int(raw_input()) b = int(raw_input()) if 1 <= a <= 10 ** 8: if a <= b <= 10 ** 8: for i in range(a, b+1): if float(i**Fraction(1,3)).is_integer() == True: …
Willie3838
  • 31
  • 2
2
votes
2 answers

Javascript function to determine if a value is an integer

I came across a problem where I needed to determine if the field being entered by the user was an integer or float. The answer would then preselect a drop down further along a form. After much digging I found lots of framework code but none that…
2
votes
3 answers

How to check if a number is an integer in .NET?

Say I've got a string which contains a number. I want to check if this number is an integer. Examples IsInteger("sss") => false IsInteger("123") => true IsInterger("123.45") =>false
Martin
2
votes
3 answers

PHP - need clarification on is_int() and while loop

I want to convert a decimal number to an integer by multiplying it by 10 until it gives me an integer. Example: 0.2 should become 2 and 0.004 should become 4 Here is my function function make_integer($num){ if (!is_int($num)){ $temp =…
2
votes
2 answers

Check to see if string is an integer (includes negative numbers) PHP

The function below checks if a string is an integer meaning it should only contain digits. But it does not check if number is negative (negative numbers should return true as well since they are integers). function validateInteger($value) { …
GGio
  • 7,563
  • 11
  • 44
  • 81
1
vote
2 answers

asp.net mvc 3 using IsInt() in controller

I would like to check if my variable is an integer in controller. In view I can easily use isInt() but not in the controller. Do I need to have a special reference to use that method? Thank you.
bobek
  • 8,003
  • 8
  • 39
  • 75
1
vote
1 answer

check if float is integer

I have a variable score wich increases over time I but would like to print only the integer ones. like 1.0, 2.0, 3.0 et cetera. score += 0.5 if score.is_integer: print(score) But actually every score is…
Din
  • 33
  • 6
1
vote
1 answer

It doesn't append as floating Python | Problem #18

I'm writing this code for the problem #18 in Codeabbey. I need to calculate the square root of an array of numbers [150, 0, 5, 1 10, 3] I have to divide this array in three arrays (x,n) [[150, 0], [5, 1], [10 3]] where x: is the number I want to…
johnn1e
  • 55
  • 5
1
vote
6 answers

What is the most reliable way of checking if a floating point variable is an integer?

I can think of several ways, eg. Convert.ToInt32(floatingPoint) - floatingPoint == 0; Math.Truncate(floatingPoint) - floatingPoint == 0; floatingPoint % 1 == 0; Math.Floor(floatingPoint) == floatingPoint; //etc... But which method is most reliable?
ilitirit
  • 16,016
  • 18
  • 72
  • 111
1
vote
1 answer

How do you check if a string contains an int at a specific location?

I want to make sure that a folder has the correct name format before proceeding. The code below demonstrates what I am trying to do, although {char.IsDigit} doesn't work. I would like to replace char.IsDigit with something that means "any digit".…
NickyLarson
  • 139
  • 8
1
2