Announcement

Collapse
No announcement yet.

float function

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • float function

    Hallo everybody,

    i need some help

    How can i use comma numbers like " 12.5 " in simple math functions? I know it from normal C, that it works with float function, but 4D says "float not supported, value 12.5"

    pls help with a little example

    Thanks a lot

  • #2
    Picaso only supports integers, not floating point.

    In general most simple floating point math can be done in integer, it's just a matter of 'upscaling' and 'downscaling' in some way.

    Eg if 12.5 is the only decimal you could use 25, or 125 instead and adjust the result accordingly. It depends on the equation, the range of the numbers and the format/scale the ultimate answer needs to be in.
    Mark

    Comment


    • #3
      Thanks for your answer Mark.

      Ok thats bad for my projekt :/

      Comment


      • #4
        What is the full calculation you need to do?
        Mark

        Comment


        • #5
          I found a solution Thanks

          I am new in the 4d Systems, I try a lot and get better. I plan to make a computer gadget for my bike (school projekt).

          Comment


          • #6
            On pretty much any computer integer math is always faster than floating point math, so if you can 'reduce' a calculation to be done with integers without too much 'manipulation', then it will be faster to use the integer solution.
            Mark

            Comment


            • #7
              Jep thats right mark Thanks.

              Now i play with visi, but i don't get it why the button always disappears after the first hit?
              Its a simple Prog. I want to test Buttons but it works not so fine

              pls help me out

              greetings Moritz



              gfx_Set(SCREEN_MODE,LANDSCAPE) ;
              touch_Set(TOUCH_ENABLE);

              var state,button;

              // Form1 1.1 generated 04.03.2016 18:29:28

              // 4Dbutton1 1.0 generated 04.03.2016 18:29:28
              img_ClearAttributes(hndl, i4Dbutton1, I_TOUCH_DISABLE); // set to enable touch, only need to do this once
              img_Show(hndl, i4Dbutton1); // show button, only do this once
              img_SetWord(hndl, i4Dbutton1, IMAGE_INDEX, state); // where state is 0 for up and 1 for down
              img_Show(hndl,i4Dbutton1) ;



              repeat
              state := touch_Get(TOUCH_STATUS);
              button:= img_Touched(hndl, i4Dbutton1) ;

              if(touch_Get(TOUCH_STATUS) == TOUCH_PRESSED)
              switch
              case(button == i4Dbutton1)
              gfx_Cls();
              print("Button1 ist gedrueckt");
              pause(2000);
              gfx_Cls();
              break;

              case(button == -1)
              gfx_Cls();
              print("Button1 isn't hit");
              pause(2000);
              gfx_Cls();
              break;

              endswitch
              endif

              forever


              Comment


              • #8
                gfx_Cls() does what it says, it clears the screen, so anything on it will be gone. If you 'must' clear the whole screen you need to 'img_show' the buttons to get them back. Why not just clear part of the screen (with a filled rectangle of the background colour)?
                Mark

                Comment


                • #9
                  Ahhh Ok thx, but why the button don't light up when i push him ?

                  Comment


                  • #10
                    Look at the code that was pasted when you pasted the code
                    Code:
                    mg_SetWord(hndl, i4Dbutton1, IMAGE_INDEX, state); // where state is 0 for up and 1 for down
                    img_Show(hndl,i4Dbutton1)
                    What's the comment say on the first line?

                    You need to change and reshow the state.

                    HAve a look at some of the supplied examples more closely
                    Mark

                    Comment


                    • #11
                      I i'll take a closer look
                      still a lot to learn for me
                      Thanks

                      Comment

                      Working...
                      X