Starfinder Playlist
Page 89 of 104 First ... 39 79 87 88 89 90 91 99 ... Last
  1. #881
    Ampersandrew's Avatar
    Join Date
    Nov 2017
    Location
    Belfast, Northern Ireland
    Posts
    247
    Quote Originally Posted by dulux-oz View Post
    The rounding issue is also being worked on - its an issue with the way computers store fractional numbers, and thus integral to the FG Engine. Still, we'll see what we can do.
    Hmm, I'd rather say it's a symptom of the implementation chosen. Your answer ignores both fixed point representations and rational number implementations either of which is a much better format for currency. Someone back in the day decided these values were floating point and this is the consequence. You may have guessed, but I don't really like floating point numbers. There are lots of applications where they are a sub-optimal solution. Currency happens to be one of those applications.

    Quote Originally Posted by dulux-oz View Post
    TL;DR: its coming, but people are just going to have to be patient - I'm only one guy and there's only 24 hours in a day (and, for the record, my health isn't 100% at the moment - my issue, but it effects my productivity ).
    Sorry to hear that, get well soon.

  2. #882
    Quote Originally Posted by Ampersandrew View Post
    Hmm, I'd rather say it's a symptom of the implementation chosen. Your answer ignores both fixed point representations and rational number implementations either of which is a much better format for currency. Someone back in the day decided these values were floating point and this is the consequence. You may have guessed, but I don't really like floating point numbers. There are lots of applications where they are a sub-optimal solution. Currency happens to be one of those applications.
    Yes, but the decision to use Floats, etc, was not made by me, but is "hard-wired" into the FG-Engine - which we don't have access to (the gut of, that is) hence it taking a while to come up with a decent solution.
    Dulux-Oz

    √(-1) 2^3 Σ Π
    ...And it was Delicious!


    Alpha-Geek
    ICT Professional
    GMing Since 1982
    NSW, Australia, UTC +10
    LinkedIn Profile: www.linkedin.com/in/mjblack

    Watch our games on Twitch: www.twitch.tv/dulux_oz

    Support Me on Patreon: www.patreon.com/duluxoz

    Past Games, etc, on my YouTube Channel: www.youtube.com/c/duluxoz

  3. #883

    Join Date
    Jun 2013
    Location
    Isanti, MN
    Posts
    2,682
    Try using this:

    Code:
    function round(num, numDecimalPlaces)
      local mult = 10^(numDecimalPlaces or 0)
      return math.floor(num * mult + 0.5) / mult
    end

  4. #884
    Ampersandrew's Avatar
    Join Date
    Nov 2017
    Location
    Belfast, Northern Ireland
    Posts
    247
    Quote Originally Posted by Andraax View Post
    Try using this:

    Code:
    function round(num, numDecimalPlaces)
      local mult = 10^(numDecimalPlaces or 0)
      return math.floor(num * mult + 0.5) / mult
    end
    I haven't tried it, but I don't think that will help. It is more likely that the problem is that 0.2 is not representable exactly in this floating point representation. You will likely end up with 0.2000000098023, which is the closest this floating point representation can get to 0.2

    This needs a fix in the output layer. The real underlying problem is that lua doesn't have an integer type. Actually, I have no idea what the problem is :-)

    It's also possible that lua has been compiled with single precision floating point numbers here. Anyway, I'm sure Dulux-Oz is aware of all this and taking it into account while looking for a "decent solution".
    Last edited by Ampersandrew; October 11th, 2018 at 09:31.

  5. #885
    Yes, the Lua engine uses floating points internally for all numbers (and thus that is what the Lua scripts have to work with), which is the root of the situation.

    Regards,
    JPG

  6. #886

    Join Date
    Jun 2013
    Location
    Isanti, MN
    Posts
    2,682
    Seems to work:

    Code:
    	local nTest = 1 / 6;
    	Debug.console("Before round: " .. nTest);
    	nTest = round(nTest, 2);
    	Debug.console("After round: " .. nTest);
    Code:
    Runtime Notice: Reloading ruleset
    Runtime Notice: s'Before round: 0.16666666666667'
    Runtime Notice: s'After round: 0.17'
    Last edited by Andraax; October 11th, 2018 at 18:02.

  7. #887
    The solution Andrax listed is the method I have used for the problem of rounding.
    The capitalization problem was resolved by having the routine ignore case.

    Total Currency is first loaded into the extension and converted to copper,
    then the transaction is conducted.
    Then the resulting copper is consolidated to fewest coins using platinum as a base,
    then reinserted into the record sheet.

    The resulting vendor accurately transacts any exchange, giving proper change in return.
    I have been using this for over 6 months with good results.

    As the extension belongs to Dulux, I have not given the code to anyone.
    I do not know what effect this code will have on other extensions, but expect
    that Dulux will figure that out before incorporating it into his extension.

  8. #888

    Join Date
    Apr 2008
    Location
    Virginia Beach
    Posts
    3,093
    Intruder, he encourages people to modify his stuff and give him code in his extension threads. If you have the fix, I think he'd love to incorporate it.

  9. #889
    Quote Originally Posted by Intruder View Post
    Total Currency is first loaded into the extension and converted to copper,
    then the transaction is conducted.
    Then the resulting copper is consolidated to fewest coins using platinum as a base,
    then reinserted into the record sheet.
    Same, because merchants can also act as money lenders. or just round up and things are all dollars to make them whole numbers

    copper = 1, silver = 10, gold... etc


    sure people are n longer carrying 30k copper piece around, but nobody tracks weights once they get to town with it these days

  10. #890
    my DM track Shadzar
    KICK| TWITCH | YOUTUBE
    BRAZILIAN
    GMT-3
    FANTASY GROUNDS UNITY - ULTIMATE VERSION
    PLAYER ONLY
    FORGE CREATOR



Page 89 of 104 First ... 39 79 87 88 89 90 91 99 ... Last

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Log in

Log in