Nombre de chiffres limités dans une variable

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #183147 quote
    PepsmilePepsmile
    Participant
    Veteran

    Bonjour à tous,
    Je cherche à additionner 4 valeurs ayant chacune 6 chiffres pour obtenir 1 valeur à mettre dans un tableau de variables.
    Je m’aperçois que lorsque je veux redécomposer la valeur finale obtenue pour retrouver les 4 valeurs initiales, j’obtiens systématiquement une erreur sur les valeurs 3 et 4.
    Ces erreurs avec les mêmes formules n’apparaissent pas sur Excel.
    Question : existe-il une manière de contourner ce problème ?
    Merci d’avance de vos suggestions

    A1 = 123456//RANDOM(123456,123879)//123456
    A2 = 213655//RANDOM(213456,213879)//213655
    A3 = RANDOM(312456,312879)//312497
    A4 = RANDOM(412356,412765)//432156
    
    once f1 = pow(10,18)
    once f2 = pow(10,12)
    once f3 = pow(10,6)
    once f4 = pow(10,0)
    
    if IsLastBarUpdate then
    Aall = A1*f1 + A2*f2 + A3*f3 + A4*f4
    DRAWTEXT("Aall: #Aall#",barindex-5,6) coloured(0,0,255)
    
    rA1 = round(Aall/f1)
    if rA1 <> A1 then
    r = 255
    b = 0
    difA1 = A1-rA1
    DRAWTEXT("dif A1: #difA1#",barindex-10,5) coloured(r,0,b)
    else
    r = 0
    b = 255
    endif
    DRAWTEXT("A1: #rA1#",barindex-5,5) coloured(r,0,b)
    
    rA2 = round((Aall-rA1*f1)/f2)
    if rA2 <> A2 then
    r = 255
    b = 0
    difA2 = A2-rA2
    DRAWTEXT("dif A2: #difA2#",barindex-10,4) coloured(r,0,b)
    else
    r = 0
    b = 255
    endif
    DRAWTEXT("A2: #rA2#",barindex-5,4) coloured(r,0,b)
    
    rA3 = round((Aall-rA1*f1-rA2*f2)/f3)
    if rA3 <> A3 then
    r = 255
    b = 0
    difA3 = A3-rA3
    DRAWTEXT("dif A3: #difA3#",barindex-10,3) coloured(r,0,b)
    else
    r = 0
    b = 255
    endif
    DRAWTEXT("A3: #rA3#",barindex-5,3) coloured(r,0,b)
    
    rA4 = Aall - rA1*f1 - rA2*f2 - rA3*f3
    if rA4 <> A4 then
    r = 255
    b = 0
    difA4 = A4-rA4
    DRAWTEXT("dif A4: #difA4#",barindex-10,2) coloured(r,0,b)
    else
    r = 0
    b = 255
    endif
    DRAWTEXT("A4: #rA4#",barindex-5,2) coloured(r,0,b)
    endif// IsLastBarUpdate
    
    return 0,7// just to see Drawtext's
    #183960 quote
    NicolasNicolas
    Keymaster
    Legend

    Désolé je n’ai pas bien compris la question ? 🙂

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Nombre de chiffres limités dans une variable


ProBuilder : Indicateurs & Outils Personnalisés

New Reply
Author
author-avatar
Pepsmile @pepsmile Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by NicolasNicolas
4 years, 8 months ago.

Topic Details
Forum: ProBuilder : Indicateurs & Outils Personnalisés
Language: French
Started: 12/11/2021
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...