BitShares Forum

Main => Technical Support => Topic started by: Methodise on March 02, 2016, 01:12:24 am

Title: Jolly fucked up bug
Post by: Methodise on March 02, 2016, 01:12:24 am
(http://methodise.net/cloudy/bts-bug.png)

Most recent download. Doesn't seem to work to 4 decimals here. Misleading.
Title: Re: Jolly fucked up bug
Post by: xeroc on March 02, 2016, 08:18:14 am
in graphene, prices are ratios of two integer numbers and they are stored on the blockchain that way!
What you get displayed is a floating number that is derived (and possibly truncated) for readability reasons.
Title: Re: Jolly fucked up bug
Post by: svk on March 02, 2016, 09:50:33 am
(http://methodise.net/cloudy/bts-bug.png)

Most recent download. Doesn't seem to work to 4 decimals here. Misleading.
Some more detail would be nice. What exactly is the bug?
Title: Re: Jolly fucked up bug
Post by: Methodise on March 02, 2016, 08:09:24 pm
My problem is, I've elected to buy 10 USD at a price of 0.003875. The computer says naah and counter-offers me 0.0038. If that isn't a feature, it's a bug.

My confirmation dialogue is expressing the price inversely to my writing it, which is slightly frustrating - that confirmation figure isn't something i can work with unless I fetch a calculator. But when I do so, I realise all of my precision orders have been rounded down. However, orders to 6 decimals do appear in the order book, and so far as I can tell I have been able to generate some of them myself, perhaps only when the interface is orientated the other way, (BTS:USD /  USD:BTS).

While I'm at it, I had a similar gripe with the interface when it offered me the ability to pay a transaction fee in 30 BTS or X USD. I chose to pay in BTS, and was charged 32 BTS. Certainly, that might be how things are supposed to work when transferring USD or whatever I was doing, but as finicky as it may seem, where it comes to financial exchange software, things like fees and decimal places being as written, do matter.
Title: Re: Jolly fucked up bug
Post by: tonyk on March 02, 2016, 08:33:12 pm
... where it comes to financial exchange software, things like fees and decimal places being as written, do matter.

every serious person will run or laugh when he sees floating point math being used in a 'financial' platform. It is a joke or a toy but  not a financial platform...

But when I say something like that... a 'complainer' and not a doer I am promptly called... so I will just shut up... and fix it.
Title: Re: Jolly fucked up bug
Post by: tonyk on March 02, 2016, 08:49:09 pm
It is not over complected. The code is below, the worker to pay for it coming soon  :)

Code: [Select]
// Closure
(function() {
  /**
   * Decimal adjustment of a number.
   *
   * @param {String}  type  The type of adjustment.
   * @param {Number}  value The number.
   * @param {Integer} exp   The exponent (the 10 logarithm of the adjustment base).
   * @returns {Number} The adjusted value.
   */
  function decimalAdjust(type, value, exp) {
    // If the exp is undefined or zero...
    if (typeof exp === 'undefined' || +exp === 0) {
      return Math[type](value);
    }
    value = +value;
    exp = +exp;
    // If the value is not a number or the exp is not an integer...
    if (isNaN(value) || !(typeof exp === 'number' && exp % 1 === 0)) {
      return NaN;
    }
    // Shift
    value = value.toString().split('e');
    value = Math[type](+(value[0] + 'e' + (value[1] ? (+value[1] - exp) : -exp)));
    // Shift back
    value = value.toString().split('e');
    return +(value[0] + 'e' + (value[1] ? (+value[1] + exp) : exp));
  }

  // Decimal round
  if (!Math.round10) {
    Math.round10 = function(value, exp) {
      return decimalAdjust('round', value, exp);
    };
  }
  // Decimal floor
  if (!Math.floor10) {
Math.floor10 = function(value, exp) {
      return decimalAdjust('floor', value, exp);
    };
  }
  // Decimal ceil
  if (!Math.ceil10) {
    Math.ceil10 = function(value, exp) {
      return decimalAdjust('ceil', value, exp);
    };
  }
})();
Title: Re: Jolly fucked up bug
Post by: abit on March 03, 2016, 12:26:46 am
While I'm at it, I had a similar gripe with the interface when it offered me the ability to pay a transaction fee in 30 BTS or X USD. I chose to pay in BTS, and was charged 32 BTS. Certainly, that might be how things are supposed to work when transferring USD or whatever I was doing, but as finicky as it may seem, where it comes to financial exchange software, things like fees and decimal places being as written, do matter.
Default transfer fee was 30 BTS if you transfer without a memo. If you have a memo, there will be an additional data-size fee (x per kb). See https://cryptofresh.com/fees
Title: Re: Jolly fucked up bug
Post by: mint chocolate chip on March 03, 2016, 12:30:48 am
While I'm at it, I had a similar gripe with the interface when it offered me the ability to pay a transaction fee in 30 BTS or X USD. I chose to pay in BTS, and was charged 32 BTS. Certainly, that might be how things are supposed to work when transferring USD or whatever I was doing, but as finicky as it may seem, where it comes to financial exchange software, things like fees and decimal places being as written, do matter.
Default transfer fee was 30 BTS if you transfer without a memo. If you have a memo, there will be an additional data-size fee (x per kb). See https://cryptofresh.com/fees
I asked the same thing last week when I paid more in fees than what was stated as the transfer fee. The memo field needs to explain this otherwise it looks like an overcharge to every user.
Title: Re: Jolly fucked up bug
Post by: abit on March 03, 2016, 11:22:17 am
While I'm at it, I had a similar gripe with the interface when it offered me the ability to pay a transaction fee in 30 BTS or X USD. I chose to pay in BTS, and was charged 32 BTS. Certainly, that might be how things are supposed to work when transferring USD or whatever I was doing, but as finicky as it may seem, where it comes to financial exchange software, things like fees and decimal places being as written, do matter.
Default transfer fee was 30 BTS if you transfer without a memo. If you have a memo, there will be an additional data-size fee (x per kb). See https://cryptofresh.com/fees
I asked the same thing last week when I paid more in fees than what was stated as the transfer fee. The memo field needs to explain this otherwise it looks like an overcharge to every user.
Please submit an issue or pull request to github https://github.com/cryptonomex/graphene-ui/issues if you have good practical suggestions. For example: place what text at what position of what page. Best a screenshot or visual page design. Thanks!
Title: Re: Jolly fucked up bug
Post by: svk on March 03, 2016, 02:33:44 pm
My problem is, I've elected to buy 10 USD at a price of 0.003875. The computer says naah and counter-offers me 0.0038. If that isn't a feature, it's a bug.

My confirmation dialogue is expressing the price inversely to my writing it, which is slightly frustrating - that confirmation figure isn't something i can work with unless I fetch a calculator. But when I do so, I realise all of my precision orders have been rounded down. However, orders to 6 decimals do appear in the order book, and so far as I can tell I have been able to generate some of them myself, perhaps only when the interface is orientated the other way, (BTS:USD /  USD:BTS).

While I'm at it, I had a similar gripe with the interface when it offered me the ability to pay a transaction fee in 30 BTS or X USD. I chose to pay in BTS, and was charged 32 BTS. Certainly, that might be how things are supposed to work when transferring USD or whatever I was doing, but as finicky as it may seem, where it comes to financial exchange software, things like fees and decimal places being as written, do matter.

You're right, there's a new bug here that occurs when a price is entered with an amount of decimals that exceeds the precision of the asset you're using to define the price. In this case, USD precision is 4 decimals, so the parts of the price beyond that were truncated. I'll push a fix for it using a function find the correct integer ratio.

If you don't like the market direction used for the price display, you can click on it to flip it. That setting will then be applied to and remembered for that market pair. Due to the way prices are represented there's no way to know the "correct" direction for an order so it just has to be that way.
Title: Re: Jolly fucked up bug
Post by: svk on March 03, 2016, 03:23:52 pm
Should be ok once this goes live: https://github.com/cryptonomex/graphene-ui/issues/757
Title: Re: Jolly fucked up bug
Post by: Methodise on March 10, 2016, 01:18:23 am
Thanks doods.  +5%

I'll endeavour to direct further bug reports directly to the github.