limit of int in c++ code example

Example 1: how to change double to int in java

class Scratch{
    public static void main(String[] args){
        double decimal = 5.7;
        System.out.println( (int) decimal );	//casting
        System.out.println( Math.round(decimal * 10) / (double) 10);	//Math.round()
        System.out.println( decimal % 1);	// modulus
        System.out.println( Integer.parseInt( String.valueOf(decimal).substring(0, String.valueOf(decimal).indexOf(".")))); // .substring()
    }
}

Example 2: maximum int c++

#include <limits>

int imin = std::numeric_limits<int>::min(); // minimum value
int imax = std::numeric_limits<int>::max(); // maximum value (2147483647)

Example 3: int max in c++

2147483647
  unsigned long long int = 18 446 744 073 709 551 615

Example 4: multiplication of string with int in python

#multiplying string with a integer
"superman " * 5
# It will return a new string

Tags:

Cpp Example