Results 1 to 5 of 5

Thread: Faster Maths with LongLong / Floating numbers

  1. #1

    Thread Starter
    Frenzied Member some1uk03's Avatar
    Join Date
    Jun 2006
    Location
    London, UK
    Posts
    1,663

    Faster Maths with LongLong / Floating numbers

    I've some C code that I've converted to VB.

    I've been working on some precision Maths that require at least 18 decimal point precision.
    My way around it was to use VARIANTS and then VariantChangeTypeEx to make it in to a LongLong.

    Everything works fine. Only issue is, it's pretty slow in VB, especially on a long loop! and it's instant in C

    I'm tempted to test the ThunderVB add-in (where you can run C code right in the VB IDE) but that simply doesn't seem to work with win10. There's another option with RTCC but i can't get my head round that too.

    Any ideas you guys can think that would/could help this?
    _____________________________________________________________________

    ----If this post has helped you. Please take time to Rate it.
    ----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.



  2. #2

  3. #3
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,120

    Re: Faster Maths with LongLong / Floating numbers

    Quote Originally Posted by some1uk03 View Post
    There's another option with RTCC but i can't get my head round that too.
    RTCC does not support __int64 so have to manually impl all operations.

    cheers,
    </wqw>

  4. #4
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Faster Maths with LongLong / Floating numbers

    If the issue is just the need to do some mass computation more quickly why not just write a static DLL in C and invoke that from your VB6 program?

  5. #5
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,120

    Re: Faster Maths with LongLong / Floating numbers

    Btw, check this out

    Code:
    Option Explicit
    
    Private Declare Function LongLongMul Lib "ntdll" Alias "_allmul" (ByVal cFirst As Currency, ByVal cSecond As Currency) As Currency
    
    Private Sub Form_Load()
        Dim a As Currency
        Dim b As Currency
        Dim c As Currency
        
        a = 12 / 10000@
        b = 34 / 10000@
        c = LongLongMul(a, b) * 10000@
        Debug.Assert c = 12 * 34
    End Sub
    And it seems that all of the rest of C/C++ compiler intrinsics for dealing with __int64 are present in ntdll.dll too

    Code:
         2005   0x0002E2C0    _alldiv
         2006   0x0002E370    _alldvrm
         2007   0x0002E460    _allmul
         2011   0x0002E4C0    _allrem
         2012   0x0002E580    _allshl
         2013   0x0002E5A0    _allshr
         2014   0x000E1F22    _atoi64
         2015   0x0002E600    _aulldiv
         2016   0x0002E670    _aulldvrm
         2017   0x0002E710    _aullrem
         2018   0x0002E790    _aullshr
    These API functions would be best to be available from a typelib to skip GetLastError call.

    Edit: Here is one alt implementation of these APIs -- https://source.winehq.org/source/dlls/ntdll/large_int.c

    cheers,
    </wqw>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width