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

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #35211 quote
    laurenzo
    Participant
    Average

    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 quote
    zen83
    Participant
    Senior

    fonction ROUND

    #35215 quote
    laurenzo
    Participant
    Average

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

    #35219 quote
    laurenzo
    Participant
    Average

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

    partieentiere = nombre - (nombre MOD 1)

    Si quelqu’un a un truc moins sale… 🙂

    robertogozzi and Nicolas thanked this post
    #35227 quote
    zen83
    Participant
    Senior

    Alors Prorealtime écrit n’importe quoi

    laurenzo thanked this post
    2017-05-11-ProBuilder-Création-dindicateur-Mon-indicateur11.jpg 2017-05-11-ProBuilder-Création-dindicateur-Mon-indicateur11.jpg
    #35238 quote
    laurenzo
    Participant
    Average

    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 quote
    LaMaille
    Participant
    Junior

    // 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)

    Nicolas and Louloute thanked this post
    #182732 quote
    Louloute
    Participant
    Average

    Un grand MERCI !!!

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

    #182735 quote
    JC_Bywan
    Moderator
    Master

    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”:

    FLOOR

    CEIL

    Louloute thanked this post
Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.

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


ProBuilder : Indicateurs & Outils Personnalisés

New Reply
Author
author-avatar
laurenzo @laurenzo Participant
Summary

This topic contains 8 replies,
has 2 voices, and was last updated by JC_Bywan
4 years, 3 months ago.

Topic Details
Forum: ProBuilder : Indicateurs & Outils Personnalisés
Language: French
Started: 05/11/2017
Status: Active
Attachments: 1 files
Logo Logo
Loading...