current position:Home>Why is the price data type returned by the price feed of chainlink int?

Why is the price data type returned by the price feed of chainlink int?

2022-02-04 00:18:22 Q & A of Denglian community

pragma solidity ^0.6.7;import "@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol";contract PriceConsumerV3 {    AggregatorV3Interface internal priceFeed;    /**     * Network: Kovan     * Aggregator: ETH/USD     * Address: 0x9326BFA02ADD2366b30bacB125260Af641031331     */    constructor() public {        priceFeed = AggregatorV3Interface(0x9326BFA02ADD2366b30bacB125260Af641031331);    }    /**     * Returns the latest price     */    function getThePrice() public view returns (int) {        (            uint80 roundID,             int price,            uint startedAt,            uint timeStamp,            uint80 answeredInRound        ) = priceFeed.latestRoundData();        return price;    }}

In the code ,price The type is int type , Why use a type containing negative numbers to represent price data ?






Other answers 1:

copyright notice
author[Q & A of Denglian community],Please bring the original link to reprint, thank you.
https://en.netfreeman.com/2022/02/202202040018204020.html

Random recommended