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