[Question]
  [
A number is [whole](https://en.wikipedia.org/wiki/Natural_number) if it is a non-negative integer with no decimal part. So `0` and `8` and `233494.0` are whole, while `1.1` and `0.001` and `233494.999` are not.
---
## Input
A floating-point number in the default base/encoding of your language. 
For example, the default integer representation for [Binary Lambda Calculus](//esolangs.org/wiki/Binary_lambda_calculus) would be [Church numerals](https://en.wikipedia.org/wiki/Church_encoding). But the default integer representation for [Python](//python.org) is [*base 10 decimal*](https://en.wikipedia.org/wiki/Decimal), not [Unary](https://en.wikipedia.org/wiki/Unary_numeral_system).
## Output
A [truthy](https://codegolf.meta.stackexchange.com/a/2194/60919) value if the input is whole, a [falsy](https://codegolf.meta.stackexchange.com/a/2194/60919) value if it is not.
Note that if your language only supports decimal precision to, say, 8 places, `1.000000002` can be considered whole.
Input and output may be done via any [standard I/O methods](https://codegolf.meta.stackexchange.com/q/2447/61563).
---
# Test cases
```
Input        -> Output
332          -> true
33.2         -> false
128239847    -> true
0.128239847  -> false
0            -> true
0.000000000  -> true
1.111111111  -> false
-3.1415926   -> false
-3           -> false
```
---
# Scoring
As with [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), the shortest submission wins. Good luck!
  
[Answer]
# [Haskell](https://www.haskell.org/), ~~27~~ 16 bytes
This function checks whether `x` is contained in the list of nonnegative integers that are not greater than `x`.
```
f x=elem x[0..x]
```
[Try it online!](https://tio.run/##y0gszk7Nyfn/P02hwjY1JzVXoSLaQE@vIvZ/bmJmnoKtQkFRZl6JgkaagrGeoYmhqaaCgp0dsqABEGiiiGnoGmpq/gcA "Haskell – Try It Online")
[Answer]
# [APL (Dyalog)](https://www.dyalog.com/), 3 bytes
```
⌊≡|
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///P@1R24RHPV2POhfWADkKxsZGXCBSD0QZGlkYGVtamJgD2QZ6KDywiAEMgNTqGcIAkHdovbGeoYmhqaWRGYQHAA "APL (Dyalog Unicode) – Try It Online")
Note that `f←` has been prepended in the TIO link due to technical limitations, but it's not normally needed.
[Answer]
# Pyth, 4 bytes
```
qs.a
```
[Test suite](https://pyth.herokuapp.com/?code=qs.a&test_suite=1&test_suite_input=332%0A33.2%0A128239847%0A0.128239847%0A0%0A0.000000000%0A1.111111111%0A-3.1415926%0A-3&debug=0)
Is the number equal (`q`) to the floor (`s`) of its absolute value (`.a`)?
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), ~~17~~ ~~15~~ 14 bytes
*Saved 1 byte thanks to Not a tree!*
```
#>=0==#~Mod~1&
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n2Zl@1/ZztbA1la5zjc/pc5Q7X9AUWZeSbRGtbJOWrRybK2apr5DtbGxkY6xsZ6RjqGRhZGxpYWJuY6BHhIbyDOAAR1DPUMY0NE11jM0MTS1NDIDMmtj/wMA "Wolfram Language (Mathematica) – Try It Online")
First Mathematica answer \o/
## Mathematica, 15 bytes
*Saved 2 bytes thanks to @user202729!*
```
#==⌊Abs@#⌋&
```
[Answer]
# [Husk](https://github.com/barbuz/Husk), 3 bytes
```
£ΘN
```
[Try it online!](https://tio.run/##yygtzv6vkKtR/KipsUjz0Lb/hxafm@H3//9/Y2MjLmNjPSMuQyMLI2NLCy4DPSjLxJzLAMgzgAEuQz1DGODSNdYzNDE0tTQyAzIB "Husk – Try It Online")
The third test case times out in TIO, so I chopped off a couple of digits.
I tried to run it locally, but killed it after a couple of minutes since it was using over 6GB of memory and my computer started to stutter.
It should theoretically finish at some point...
## Explanation
This corresponds to the challenge description pretty directly.
```
£ΘN  Implicit input: a number.
  N  The infinite list [1,2,3,4...
 Θ   Prepend 0: [0,1,2,3,4...
£    Is the input an element of this list?
```
[Answer]
# [Python 2](https://docs.python.org/2/), 18 bytes
```
lambda n:n%1==0<=n
```
[Try it online!](https://tio.run/##K6gsycjPM/qfZhvzPycxNyklUSHPKk/V0NbWwMY2739icXFqUYlCmoaxsZGmQmaxQkhRaSoXkqgeRNgtMacYSdzQyMLI2NLCxByLHgM9VFk0rQZYtRjAABZZQz1DGMBmoK6xnqGJoamlkRl2WSTRgqLMvBINJcecHIWS1OKSYoUCkLoUPSXN/wA "Python 2 – Try It Online")
[Answer]
# [///](https://esolangs.org/wiki////), 94 bytes, input hard-coded
```
/=/\/x://:/\/\///-0/-:.0/.:.|/|:-|/|:0=1=2=3=4=5=6=7=8=9=|x/|:||/true:x:/-:/.:/|/+:++/false/||
```
[Try it online!](https://tio.run/##FYw7DoAgFAQPRGDxry/Zm9BQYCyoRBOKd3fEZqeYzJYcy5VKayACqgDSGQBYDyvOw4lTqNh/PAeOnDhz4cqNOw9q7UIVz/0m6QdWegKFEWNwxlwSVFv7AA "/// – Try It Online")
Input between the two terminating vertical lines (`||`)
Strips `-00...0` and `.00...0`, converts all remaining digits to `x`s, then tests whether the remaining number still has `x`s after `.` or a `-` not followed by `.`.
Could save up to 7 bytes depending on what's counted as truthy and falsey since this language doesn't have native truthy/falsey values, currently is outputting `true` and `false` but could change to, for example, `T` and `F` for 87 bytes if that's allowed.
[Answer]
# [Python 2](https://docs.python.org/2/) and [Python 3](https://docs.python.org/3/), ~~21~~ 18 bytes
```
lambda n:n>=0==n%1
```
[Try it online! (Py2)](https://tio.run/##K6gsycjPM/qfZhvzPycxNyklUSHPKs/O1sDWNk/V8H9BUWZeiUaahrGxkaYmF4Knh8w1NLIwMra0MDFHEjPQwyqKosIABpDN0jOEASRRXWM9QxNDU0sjMxRBTc3/AA "Python 2 – Try It Online")  
[Try it online! (Py3)](https://tio.run/##K6gsycjPM/6fZhvzPycxNyklUSHPKs/O1sDWNk/V8H9BUWZeiUaahrGxkaYmF4Knh8w1NLIwMra0MDFHEjPQwyqKosIABpDN0jOEASRRXWM9QxNDU0sjMxRBTc3/AA "Python 3 – Try It Online")
3 bytes saved thanks to Mr. XCoder.
[Answer]
# [Octave](https://www.gnu.org/software/octave/), 15 bytes
```
@(x)any(x==0:x)
```
[Try it online!](https://tio.run/##y08uSSxL/Z9mq6en999Bo0IzMa9So8LW1sCqQvN/moaxsZECFGgqKKgqlBSVpnKBhPWMkIXTEnOKQeKGRhZGxpYWJuaoyg304BIoyg0UFLCZbqBnAAPIwoZ6hjCAYoqusZ6hiaGppZGZApo4qulg8f8A "Octave – Try It Online")
This one is based on the approach used in [@flawr's Haskell answer](https://codegolf.stackexchange.com/a/148476/42295).
While it brings the byte count down to 15, it is shamefully inefficient (no offence intended), creating a list of every integer from `0` to `x` and seeing if `x` is contained within.
---
# [Octave](https://www.gnu.org/software/octave/), 18 bytes
```
@(x)fix(x)==abs(x)
```
[Try it online!](https://tio.run/##bYxJCoAwDEX3niIbQReGJnVcFLxKFQuCIDjh7euAihX/IoH3P6@vJ7001ihEtGWwhqZd96uUrsb9WxNIyXAlBPBhGubGOzDyGxvdjQcnzlkWeZy5c4FP4cwFwJ9doLjzxoR0x7FEEimmpOAUPty1n9xu "Octave – Try It Online")
Takes input as a double precision number. Returns true if whole.
Checks if the input when rounded is equal to the magnitude of the input. This will only be the case when the number is positive and whole.
---
# [Octave](https://www.gnu.org/software/octave/), 18 bytes
```
@(x)~mod(x,+(x>0))
```
[Try it online!](https://tio.run/##y08uSSxL/Z9mq6en999Bo0KzLjc/RaNCR1ujws5AU/N/moaxsZECFGgqKKgqlBSVpnKBhPWMkIXTEnOKQeKGRhZGxpYWJuaoyg304BIoyg0UFLCZbqBnAAPIwoZ6hjCAYoqusZ6hiaGppZGZApo4qulg8f8A "Octave – Try It Online")
An alternate solution for 18 bytes. Sadly the `mod` function in Octave won't implicitly convert a `bool` to a `double`, so the `+( )` is needed around the greater than comparison. Otherwise this solution would have been shorter.
---
# [Octave](https://www.gnu.org/software/octave/), 18 bytes
```
@(x)x>=0&~mod(x,1)
```
[Try it online!](https://tio.run/##y08uSSxL/Z9mq6en999Bo0Kzws7WQK0uNz9Fo0LHUPN/moaxsZECFGgqKKgqlBSVpnKBhPWMkIXTEnOKQeKGRhZGxpYWJuaoyg304BIoyg0UFLCZbqBnAAPIwoZ6hjCAYoqusZ6hiaGppZGZApo4qulg8f8A "Octave – Try It Online")
And another one... ~~I can't seem to get lower than 18 bytes~~. All because of having to allow for 0 to be true with the `>=` instead of just `>`.
[Answer]
# [C++ (gcc)](https://gcc.gnu.org/), 33 bytes
```
int f(float x){return(uint)x==x;}
```
[Try it online!](https://tio.run/##PU9di4MwEHz3Vyz0xdBUNGnvzqr3R45SJCZHQGPRDciJv91bE@g87NcMw6x6vS6/Su0n61TvOw21HWecdDt879YhmNT0Y4uwsHXS6CeXejqzpWmWaguKobUuZcmaACGKnR/mnwc0sIKUgkuZCcML8XX95HlGXciSZsNzWnMCkVnxhuEXmRXX4laKj2OGrYre45TO9k8/EZC884paDWUF5zOyoIgZDszY3e9q9KSo6YcQCB/s2AKlXddH1y3U@Bt5Jtv@Dw "C++ (gcc) – Try It Online")
[Answer]
# [Aceto](https://github.com/aceto/aceto), 6 bytes
```
rfdi±=p
```
```
r grabs input
f converts it to a float
d and i duplicates it and converts it to an integer
± pushes the absolute value of it (b/c can't be negative)
= checks if they are equal
p prints out the result
```
[Try it online!](https://tio.run/##S0xOLcn//78oLSXz0Ebbgv//jfUMDMwB "Aceto – Try It Online")
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 6 bytes
```
&gQZsI
```
[Try it online!](https://tio.run/##K6gsyfj/Xy09MKrY8/9/XWM9AwMDAA "Pyth – Try It Online")
[Answer]
# [QBIC](https://drive.google.com/drive/folders/0B0R1Jgqp8Gg4cVJCZkRkdEthZDQ), 17 bytes
```
?(:=int(a))*(a>0)
```
## Explanation
```
?             PRINT
 (:=int(a))     if the input (: assigns the cmd line param to 'a') equals itself 
                cast to int, -1 else 0
 *              times
 (a>0)          if the input > 0, -1 else 0
```
If either check fails, this returns 0. If both are true, it returns -1 x -1 = 1
[Answer]
# C (gcc), ~~27~~ ~~28~~ ~~27~~ 25 bytes
*-2 thanks to PrincePolka*
```
#define g(f)!fmod(f,f>=0)
```
[Try it online!](https://tio.run/##bY/fCoIwGMXvfYqlCBvocJuRUvkk3Yz90YGbkRZC9OrZivBCPZfnd873cURaCzFFxon2LhU4WT40uKmmSCptnAI11GinbSehTnR1ztBMBtUPgvcKjghcb8YNGoaxBDDW6OLCxDdHlIARHYPAQ2C5cfDRGYmCZwC85j5jFGc@tjAxXXqEFpSVRX5YxzM8wzXaSGc/rR5g8teSpAyTnOzLDf975TX5EW@hW173U9raDw)
Defines a macro "function" `g` that takes a parameter `f` (of any type). Then checks if casting `f mod 1` is zero, and if `f` is non-negative.
[Answer]
## C#, Java : 43 bytes
-1 byte thanks to Zacharý  
-1 byte thanks to TheLetalCoder
```
int w(float n){return(n==(int)n&&n>=0)?1:0;}
```
C# has a special 33 bytes optimization that you can not do in java : 
```
bool w(float n){return(int)n==n;}
```
### For testing
C# code :
```
class Program {
    int w(float n){return(n==(int)n&&n>=0)?1:0;}
    static void Main(string[] args)
    {
        var p = new Program();
        float[] fTab = new float[]{
            332,33.2f,128239847,0.128239847f,0,0.0000f,1.1111111111f,-3.1415926f,-3
        };
        foreach (float f in fTab) {
            Console.WriteLine(string.Format("{0} = {1}", f, (p.w(f) != 0).ToString()));
        }
        Console.ReadKey();
    }
}
```
Java Code :
```
public class MainApp {
    int w(float n){return(n==(int)n&&n>=0)?1:0;}
    public static void main(String[]a) {
        MainApp m = new MainApp();
        float testArr[] = new float[]{
                332,33.2f,128239847,0.128239847f,0,0.0000f,1.1111111111f,-3.1415926f,-3
        };
        for (float v : testArr) {
            System.out.println(v + " = " + String.valueOf(m.w(v)!=0));
        }
    }
}
```
[Answer]
# Google Sheets, 10 Bytes
Anonymous worksheet function that tales input from cell `A1` and outputs to the calling cell.
```
=A1=Int(A1
```
[Answer]
# [Prolog (SWI)](http://www.swi-prolog.org), 24 bytes
```
f(X):-X>=0,round(X)=:=X.
```
[Try it online!](https://tio.run/##KyjKz8lP1y0uz/z/P00jQtNKN8LO1kCnKL80LwXItbWyjdADyRgbGWnqcQFpYz0Iw9DIwsjY0sLEHMwz0EPjQ0UNYACiR88QBsB8XWM9QxNDU0sjMyhXUw8A "Prolog (SWI) – Try It Online")
[Answer]
# [Ly](https://github.com/LyricLy/Ly), ~~35~~ 47 bytes
```
ir"-"=[0u;]pr[["0"=![psp>l"."=[ppr!u;]p<2$]pp]]
```
[Try it online!](https://tio.run/##y6n8/z@zSElXyTbaoNQ6tqAoOlrJQMlWMbqguMAuR0kPKF5QUKQIkrIxUoktKIiN/f/fxMhYz8DUxAgA "Ly – Try It Online")
Ly has float support, but the only way to create a float currently is by performing division. There is no way to take a float as input, so I had to manually check the string instead.
Lost 13 bytes adding support for negative numbers.
[Answer]
# JavaScript, 14
```
n=>!(n<0||n%1)
```
[Answer]
# Perl 5, 11 +1(-p) bytes
```
$_=abs==int
```
The `-l` switch not counted because for tests display
[try it online](https://tio.run/##TccxDoAgDEDRvedwhdAWFAbOYjRxICFAhPNbXUj80/vturMTWfZ4nD3GVIYIMwGzJkDyxMHbDYz@@TszA9Q4M6BYo0UXaP341DZSLV1Uyy8)
[Answer]
# [Perl 6](https://perl6.org), ~~15~~ 13 bytes
```
{.narrow~~UInt}
```
[Test it](https://tio.run/##ZY5PT4NAEMXv@ykmTRXWwpRdKraSNl6966n2QOiSkCywsot/QugX8@YXQ6gt0vhOk99782aUKGXQVlrAW4BxSLJPuI6LvYB1W2MelWXxfjg8P@amaTvrwQhtYA0yzYW26fcXaiVTY89f9A1Y7saCbphTzCJ1X8MMt97OAdyyHYhXsExZCQsa0l976opComSUw@zYGpKkKE8H3A3Y0zRXlXFgKj6UiI3YU6gJQKqhf@9k05HvwOQXYpIZ27piXFu0rxoSKGObTkjT@j6HQV2if4z4PvIxTCKpBWF8yf3VcnE3jno4wkPUA/jf6qF31h9kyM4a7bs@sgW7XfEALuhl65H@AA "Perl 6 – Try It Online")
```
{.Int==$_>=0}
```
[Test it](https://tio.run/##ZY5PT4NAEMXv@ykmDbpgYcruVmwlNF69e6uNIXRJSBaK7GI0hE/mzS@G0D9I4ztNfu/NmyllpYKu1hI@AkxCkn/BbXLYS4i6Bp8LE0XW2yby2643nozUBiJQWSG17fx8oy5VZuzFq74D6m0o9MPCwTwuHxuY49bfuYBbtgP5DtRUtaTQkuHWS18UklLFBcyPrSFJD9X5gLcB28qKsjYuWPKzlImRewcaApBpGJ47287Ed2F2gpjmxqY3jGvqDFVjAlViOzPSdkJwGNUnhseIEMinMI2VloTxFRfr1fJhGvVxgseoD/C/1Uf/oj/IkF002fcEsiW7X/MAruh165H@Ag "Perl 6 – Try It Online")
[Answer]
# [Java (OpenJDK 8)](http://openjdk.java.net/), 14 bytes
```
n->n%1==0&n>=0
```
[Try it online!](https://tio.run/##ZZBBa4QwEIXv/oq5dFHQrNFtu9uip14LhT2WHrKaLHHdRMy4UIq/3UZTi7UDyZB8897Aq9iNRbrhqiovQ9OdallAUTNj4JVJBV8ewM@vQYa23bQs4WqZf8RWqvP7B7D2bIJpFKCyfqRDWRPRqQKlVuRFWwP@1vJSFgw5iGxQUa7uaJbFG5Vn8fA8SctpzvohN2ggs45pmoTwW9stRDlg23ELyII4IFhtuEeTfZIe9rvHcCWJyRItJfFix0oSzxX@AZTQuVZeUUrojt4fkocQ1uT/FkfGd@8yELoF3wUxxfDkwpjTBTh@GuRXojskjY0fa@ULMs744xUEzqb3xtMP3w "Java (OpenJDK 8) – Try It Online")
[Answer]
# C#, ~~40~~ ~~37~~ 29 bytes
```
bool z(float x)=>x%1==0&x>=0;
```
Saved 8 bytes thanks to @Dennis\_E!
Old Answer (37 bytes)
```
bool z(float x){return x%1==0&&x>=0;}
```
Old old answer (40 bytes):
```
bool z(float x){return (int)x==x&&x>=0;}
```
[Answer]
# JavaScript, ~~17~~ 15 bytes
```
_=>_<0?0:_==~~_
```
```
_=>_<0?0:_==(_|0)
```
Thanks to edc65 for catching my mistakes.
[Answer]
# Unexpanded Sinclair ZX81, 20 bytes
```
 1 INPUT A
 2 PRINT ABS A=INT A
```
20 bytes because BASIC is tokenized.
Simply will output 1 (true) if number is positive and the value of the number entered equals its integer value. Outputs 0 either of those conditions are not met.
[Answer]
## C, C++ : ~~38~~ 37 bytes
-1 byte thanks to Zacharý
-1 byte thanks to ceilingcat
```
int w(float n){return(int)n==n&n>=0;}
```
### For Testing
C : [Try it online](https://tio.run/##PU/BboMwDL33K6xMrRI1jULSdaUp3YdsPSBKViQWpmDUA@LbmYGt72A/y8/PdrH7KorxpQpF3d1KOLd4qxp1v4xVQHhwXzc5QhB9LLGLAUKWceqIsNmES6bdMOu@8ypwAf0KCMuI/7hCBj1Ya6S1yniZmKOx6XH/JrV6ci81lZpAApU84eXOqmSfvKbmMHEY3Gw@bcOF@iYCB6Qt2lE6Q@pgu8X/Myb8RNJ7ztaeVOv2MzBJh@FVTp9RFu8MY1eyE/N13pZMLM7DHP8@1m41jL8)
C Code :
```
#include <stdio.h>
int main() {
    float f[] = { 332,33.2f,128239847,0.128239847f,0,0.0000f,1.1111111111f,-3.1415926f,-3 };
    int t;
    for ( t = 0; t < 9; ++t) {
        printf("%f = %s\n", f[t], w(f[t])?"true":"false");
    }
    return 0;
}
```
C++ Code :
```
#include <iostream>
int main() {
    std::initializer_list <std::pair<float,bool>> test{
        {332.f,true}, {33.2f,false}, {128239847.f,true}, {0.128239847f,false}, {0.f,true}, {0.000000f,true}, {1.111111f,false}, {-3.1415926f,false}, {-3.f,false}
    };
    for (const auto& a : test) {
        if (w(a.first) != a.second) {
            std::cout << "Error with " << a.first << '\n';
        }
    }
    return 0;
}
```
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), 11 bytes
```
n=>n<0==n%1
```
[Try it online!](https://tio.run/##ZcxBDoIwEAXQPafoxqTVMrQFFYLlIsZIg4VosBCoXr9qDFjiX8zi5c@/qacaq@Ha29B0F@1q6YwszIFJaVbc5UEZxLFAc8IC2eGh3wjCx1q1ow64SEWcpcnerzLweK4yhP5XGbApP@TAp3j/YQw84dtM7NBCl6tfLWHQfasqjSMMaxIWnxvdG4rPVFNLZFF1ZuxaDW3X4GONN5pQeyIkdy8 "JavaScript (Node.js) – Try It Online")
[Answer]
# [J](http://jsoftware.com/), 7 4 bytes
Removed the unnecessary celing check after the solution of Erik The Outgolfer
```
<.=|
```
[Try it online!](https://tio.run/##RczBCoAgEATQu18xdImgFl2tVPJrIokuHbzWt1sXdWBheAN75ZgQPCT@yxuFJw@iI/Qx@B4jXo@YhDj280aE1twq1a7YsnbWrEAhSRUrtU2W1A@kSgpNmpRRs@OlCfIH "J – Try It Online")
[Answer]
# Common Lisp, ~~36~~ 32 bytes
```
(lambda(n)(=(max n 0)(floor n)))
```
[Try it online!](https://tio.run/##S87JLC74r1FQlJlXoqDxXyMnMTcpJVEjT1PDViM3sUIhT8FAUyMtJz@/SCFPU1Pzv7GeARgAmQA)
Transposition of [marmeladze’s answer](https://codegolf.stackexchange.com/a/148480/41789).
[Answer]
# [Symbolic Python](https://github.com/FTcode/Symbolic-Python), 21 bytes
```
_=_%(_==_)==(_!=_)<=_
```
**[Try it online!](https://tio.run/##K67MTcrPyUzWLagsycjP@/8/3jZeVSPe1jZe09ZWI14RSNvYxv///1/XFAA "Symbolic Python – Try It Online")**
Uses a chained comparison:
* `_%(_==_) == (_!=_)` checks if `n%1 == 0`, only true if `n` has no decimal part.
* `(_!=_) <= _` checks if `0 <= n`, only true if the integer is non-negative.
]