Récupérer la partie entière d'un nombre

Forums ProRealTime forum Français Support ProBuilder Récupérer la partie entière d'un nombre

Viewing 9 posts - 1 through 9 (of 9 total)
  • #35211

    Existe-t-il une manière propre dans PRT de récupérer la partie entière d’un nombre? (comme IntPortion dans Tradestation)

    Exemple:
    1.0390191 = 1
    0.030439 = 0
    1010.201 = 1010
    1111.9 = 1111

    #35212

    fonction ROUND

    #35215

    ROUND ça arrondit. Cela ne renvoie pas la partie entière il me semble, si?

    #35219

    Je pense avoir trouvé une solution moche… mais c’est moche.

    Si quelqu’un a un truc moins sale… 🙂

    2 users thanked author for this post.
    #35227

    Alors Prorealtime écrit n’importe quoi

     

     

    1 user thanked author for this post.
    #35238

    En fait on a tous les deux raison à moitié 😀

    ROUND(1010.1001) = 1010 quand moi je veux 1010.

    ROUND(1010.6001) = 1011 quand moi je veux 1010.

    ça arrondit et ça ne prend que la partie entière.

    Donc ma solution fonctionne pour mon problème, pas ROUND 🙂

     

    #126699

    // Pour un Nombre positif

    IntPortion = ROUND(ABS(Nombre) – 0.5)

     

    // Pour un Nombre positif ou négatif

    IntPortion = SGN(Nombre) * ROUND(ABS(Nombre) – 0.5)

    2 users thanked author for this post.
    #182732

    Un grand MERCI !!!

    Je viens de récupérer la solution pour un indicateur en cours de codage.

     

    #182735

    Bonjour Louloute, depuis ce topic de 2017 de nouveaux mots-clés “floor” et “ceil” sont disponibles avec la v11, pour arrondir respectivement à l’entier en dessous (floor comme sol) même si plus proche de celui du dessus, ou arrondir à l’entier au-dessus (ceil pour ceiling=plafond) même si plus proche de l’entier en dessous, plutôt qu’à l’entier le plus proche comme le faisait “round”:

    https://www.prorealcode.com/documentation/floor/

    https://www.prorealcode.com/documentation/ceil/

     

    1 user thanked author for this post.
Viewing 9 posts - 1 through 9 (of 9 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login