home > 比較編 > Perl, PHP, Python, Ruby > arithmetic and logic >

ForNext

Only Do What Only You Can Do

034. arithmetic truncation

VBScript

JScript

Perl

# cpan -i Number::Format
use Number::Format 'round';
use POSIX qw(ceil floor);

int($x)
round($x, 0)
ceil($x)
floor($x)
abs($x)

PHP

(int)$x
round($x)
ceil($x)
floor($x)
abs($x)




Python

import math

int(x)
int(round(x))
math.ceil(x)
math.floor(x)
abs(x)


Ruby

x.to_i
x.round
x.ceil
x.floor
x.abs




PowerShell

Scala

F#

C

C++

C++Builder

VC++

C#

Java

Objective-C

D

VB

VB.NET

Delphi

Ada

PL/SQL

T-SQL

関数型

inserted by FC2 system