X-Git-Url: http://git.euphorik.ch/?p=euphorik.git;a=blobdiff_plain;f=modules%2Ferl%2Feuphorik_common.erl;h=5e3ef0966cfdcc9481e0208d70a331807d1675d0;hp=12ac9cb566a434ae716f74683a6bcc4020b05491;hb=b9dd3ee1b15f5ae030f831079072992ae04ec480;hpb=accd9081eade01ce5ebf6b54cd6f29f55f3641a7 diff --git a/modules/erl/euphorik_common.erl b/modules/erl/euphorik_common.erl index 12ac9cb..5e3ef09 100644 --- a/modules/erl/euphorik_common.erl +++ b/modules/erl/euphorik_common.erl @@ -1,5 +1,5 @@ % coding: utf-8 -% Copyright 2008 Grégory Burri +% Copyright 2008 Grégory Burri % % This file is part of Euphorik. % @@ -16,11 +16,27 @@ % You should have received a copy of the GNU General Public License % along with Euphorik. If not, see . % -% Module avec plein de bordel utile à l'intérieur +% Module avec plein de bordel utile à l'intérieur % @author G.Burri -module(euphorik_common). --export([serialize_ip/1, unserialize_ip/1]). +-export([ + serialize_ip/1, + unserialize_ip/1, + ceiling/1 +]). + + +% Arrondi un float à l'entier supérieur. +% Bizarre, cette fonction n'existe pas dans la stdlib. +% Pas utilisé mais bon ca me fait de la peine de l'enlever. +ceiling(X) -> + T = trunc(X), + case (X - T) of + Neg when Neg < 0 -> T; + Pos when Pos > 0 -> T + 1; + _ -> T + end. serialize_ip(undefined) ->