objective c - Weird decimal ending when sending object from native module to React Native javascript -


in native module resolving promise nsdictionary 1 of values amount of type nsnumber.

nsdictionary *paymentdict = [nsdictionary dictionarywithobjectsandkeys:                                      payment.orderid, @"orderid",                                      payment.transactionid, @"transactionid",                                      @(payment.amount), @"amount",                                      nil]; 

since amount number has 2 decimals e.g. 12.74. when debug can see value correct: (__nscfnumber *) (float)12.740000

however when result json object on javascript side value 12.739999771118164.

{    orderid: '123456',   transactionid: '12345678901234567890',   amount: 12.739999771118164 } 

so there happening in conversion native javascript, don't know how fix it.

the way can think of converting value string on native side, prefer keep number.

does know solution this?


Comments

Popular posts from this blog

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -