var React = require("react/addons");

var MemoryFieldComponent = React.createClass({
  displayName: "MemoryFieldComponent",
  propTypes: {
    megabytes: React.PropTypes.number.isRequired
  },
  render() {
    const megabytes = this.props.megabytes;
    return (
      <span title={`${megabytes}MB`}>{`${megabytes}MB`}</span>
    );
  }
});

module.exports = MemoryFieldComponent;

var React = require("react/addons");

var MemoryFieldComponent = React.createClass({
  displayName: "MemoryFieldComponent",
  propTypes: {
    megabytes: React.PropTypes.number.isRequired
  },
  render() {
    // For a documentation of the different unit prefixes please refer to:
    // https://en.wikipedia.org/wiki/Template:Quantities_of_bytes
    const units = ["MB", "GB", "TiB", "PiB", "EiB", "ZiB", "YiB"];
    const factor = 1024;
    const megabytes = this.props.megabytes;
    let value = 0;
    let index = 0;
    if (megabytes > 0) {
      index = Math.floor(Math.log(megabytes) / Math.log(factor));
      value = Math.round(megabytes / Math.pow(factor, index));
    }
    console.log(value, index);
    return (
      <span title={`${megabytes}MB`}>{`${value}${units[index]}`}</span>
    );
  }
});

module.exports = MemoryFieldComponent;

Add methods to round the memory value
Add methods to round the memory value

Impl. methods to round the memory and attach the correct unit, using JEDEC and IEC units.
