Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/locales.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoeybloggs <Dean.Karn@gmail.com>2016-08-13 05:03:24 +0300
committerjoeybloggs <Dean.Karn@gmail.com>2016-08-13 05:03:24 +0300
commit99657750cc781e41c9c1e3be6b6316c18fc430bd (patch)
tree3366a7d2a645600dbe8efbadc86874f94c1cedb5
parent7639a439740dfc3cdda4ae188bf3baf7cc2ff7a3 (diff)
ad variable grouping logic + cleanup generated code newlines
-rw-r--r--af/af.go18
-rw-r--r--af_NA/af_NA.go18
-rw-r--r--af_ZA/af_ZA.go18
-rw-r--r--agq/agq.go21
-rw-r--r--agq_CM/agq_CM.go21
-rw-r--r--ak/ak.go4
-rw-r--r--ak_GH/ak_GH.go4
-rw-r--r--am/am.go23
-rw-r--r--am_ET/am_ET.go23
-rw-r--r--ar/ar.go17
-rw-r--r--ar_001/ar_001.go15
-rw-r--r--ar_AE/ar_AE.go15
-rw-r--r--ar_BH/ar_BH.go15
-rw-r--r--ar_DJ/ar_DJ.go15
-rw-r--r--ar_DZ/ar_DZ.go25
-rw-r--r--ar_EG/ar_EG.go15
-rw-r--r--ar_EH/ar_EH.go15
-rw-r--r--ar_ER/ar_ER.go15
-rw-r--r--ar_IL/ar_IL.go15
-rw-r--r--ar_IQ/ar_IQ.go15
-rw-r--r--ar_JO/ar_JO.go15
-rw-r--r--ar_KM/ar_KM.go15
-rw-r--r--ar_KW/ar_KW.go15
-rw-r--r--ar_LB/ar_LB.go25
-rw-r--r--ar_LY/ar_LY.go25
-rw-r--r--ar_MA/ar_MA.go25
-rw-r--r--ar_MR/ar_MR.go25
-rw-r--r--ar_OM/ar_OM.go15
-rw-r--r--ar_PS/ar_PS.go15
-rw-r--r--ar_QA/ar_QA.go15
-rw-r--r--ar_SA/ar_SA.go15
-rw-r--r--ar_SD/ar_SD.go15
-rw-r--r--ar_SO/ar_SO.go15
-rw-r--r--ar_SS/ar_SS.go15
-rw-r--r--ar_SY/ar_SY.go15
-rw-r--r--ar_TD/ar_TD.go15
-rw-r--r--ar_TN/ar_TN.go25
-rw-r--r--ar_YE/ar_YE.go15
-rw-r--r--as/as.go22
-rw-r--r--as_IN/as_IN.go22
-rw-r--r--asa/asa.go4
-rw-r--r--asa_TZ/asa_TZ.go4
-rw-r--r--ast/ast.go15
-rw-r--r--ast_ES/ast_ES.go15
-rw-r--r--az/az.go23
-rw-r--r--az_Cyrl/az_Cyrl.go23
-rw-r--r--az_Cyrl_AZ/az_Cyrl_AZ.go25
-rw-r--r--az_Latn/az_Latn.go25
-rw-r--r--az_Latn_AZ/az_Latn_AZ.go25
-rw-r--r--bas/bas.go21
-rw-r--r--bas_CM/bas_CM.go21
-rw-r--r--be/be.go18
-rw-r--r--be_BY/be_BY.go18
-rw-r--r--bem/bem.go4
-rw-r--r--bem_ZM/bem_ZM.go4
-rw-r--r--bez/bez.go4
-rw-r--r--bez_TZ/bez_TZ.go4
-rw-r--r--bg/bg.go18
-rw-r--r--bg_BG/bg_BG.go18
-rw-r--r--bm/bm.go5
-rw-r--r--bm_ML/bm_ML.go5
-rw-r--r--bn/bn.go22
-rw-r--r--bn_BD/bn_BD.go22
-rw-r--r--bn_IN/bn_IN.go22
-rw-r--r--bo/bo.go26
-rw-r--r--bo_CN/bo_CN.go26
-rw-r--r--bo_IN/bo_IN.go26
-rw-r--r--br/br.go15
-rw-r--r--br_FR/br_FR.go15
-rw-r--r--brx/brx.go28
-rw-r--r--brx_IN/brx_IN.go28
-rw-r--r--bs/bs.go23
-rw-r--r--bs_Cyrl/bs_Cyrl.go25
-rw-r--r--bs_Cyrl_BA/bs_Cyrl_BA.go23
-rw-r--r--bs_Latn/bs_Latn.go25
-rw-r--r--bs_Latn_BA/bs_Latn_BA.go25
-rw-r--r--ca/ca.go23
-rw-r--r--ca_AD/ca_AD.go23
-rw-r--r--ca_ES/ca_ES.go23
-rw-r--r--ca_ES_VALENCIA/ca_ES_VALENCIA.go23
-rw-r--r--ca_FR/ca_FR.go23
-rw-r--r--ca_IT/ca_IT.go23
-rw-r--r--ce/ce.go23
-rw-r--r--ce_RU/ce_RU.go23
-rw-r--r--cgg/cgg.go4
-rw-r--r--cgg_UG/cgg_UG.go4
-rw-r--r--chr/chr.go23
-rw-r--r--chr_US/chr_US.go23
-rw-r--r--ckb/ckb.go4
-rw-r--r--ckb_IQ/ckb_IQ.go4
-rw-r--r--ckb_IR/ckb_IR.go4
-rw-r--r--cmd/generate_resources.go102
-rw-r--r--cmd/translator.tmpl53
-rw-r--r--cs/cs.go15
-rw-r--r--cs_CZ/cs_CZ.go15
-rw-r--r--cu/cu.go19
-rw-r--r--cu_RU/cu_RU.go19
-rw-r--r--cy/cy.go17
-rw-r--r--cy_GB/cy_GB.go15
-rw-r--r--da/da.go23
-rw-r--r--da_DK/da_DK.go23
-rw-r--r--da_GL/da_GL.go23
-rw-r--r--dav/dav.go5
-rw-r--r--dav_KE/dav_KE.go5
-rw-r--r--de/de.go23
-rw-r--r--de_AT/de_AT.go18
-rw-r--r--de_BE/de_BE.go23
-rw-r--r--de_CH/de_CH.go23
-rw-r--r--de_DE/de_DE.go23
-rw-r--r--de_LI/de_LI.go23
-rw-r--r--de_LU/de_LU.go23
-rw-r--r--dje/dje.go21
-rw-r--r--dje_NE/dje_NE.go21
-rw-r--r--dsb/dsb.go23
-rw-r--r--dsb_DE/dsb_DE.go23
-rw-r--r--dua/dua.go21
-rw-r--r--dua_CM/dua_CM.go21
-rw-r--r--dyo/dyo.go21
-rw-r--r--dyo_SN/dyo_SN.go21
-rw-r--r--dz/dz.go29
-rw-r--r--dz_BT/dz_BT.go29
-rw-r--r--ebu/ebu.go5
-rw-r--r--ebu_KE/ebu_KE.go5
-rw-r--r--ee/ee.go4
-rw-r--r--ee_GH/ee_GH.go4
-rw-r--r--ee_TG/ee_TG.go4
-rw-r--r--el/el.go23
-rw-r--r--el_CY/el_CY.go23
-rw-r--r--el_GR/el_GR.go23
-rw-r--r--en/en.go25
-rw-r--r--en_001/en_001.go23
-rw-r--r--en_150/en_150.go23
-rw-r--r--en_AG/en_AG.go23
-rw-r--r--en_AI/en_AI.go25
-rw-r--r--en_AS/en_AS.go25
-rw-r--r--en_AT/en_AT.go23
-rw-r--r--en_AU/en_AU.go23
-rw-r--r--en_BB/en_BB.go25
-rw-r--r--en_BE/en_BE.go23
-rw-r--r--en_BI/en_BI.go23
-rw-r--r--en_BM/en_BM.go23
-rw-r--r--en_BS/en_BS.go23
-rw-r--r--en_BW/en_BW.go23
-rw-r--r--en_BZ/en_BZ.go25
-rw-r--r--en_CA/en_CA.go23
-rw-r--r--en_CC/en_CC.go23
-rw-r--r--en_CH/en_CH.go23
-rw-r--r--en_CK/en_CK.go25
-rw-r--r--en_CM/en_CM.go23
-rw-r--r--en_CX/en_CX.go23
-rw-r--r--en_CY/en_CY.go25
-rw-r--r--en_DE/en_DE.go25
-rw-r--r--en_DG/en_DG.go25
-rw-r--r--en_DK/en_DK.go23
-rw-r--r--en_DM/en_DM.go23
-rw-r--r--en_ER/en_ER.go23
-rw-r--r--en_FI/en_FI.go18
-rw-r--r--en_FJ/en_FJ.go23
-rw-r--r--en_FK/en_FK.go23
-rw-r--r--en_FM/en_FM.go23
-rw-r--r--en_GB/en_GB.go23
-rw-r--r--en_GD/en_GD.go25
-rw-r--r--en_GG/en_GG.go23
-rw-r--r--en_GH/en_GH.go23
-rw-r--r--en_GI/en_GI.go23
-rw-r--r--en_GM/en_GM.go23
-rw-r--r--en_GU/en_GU.go23
-rw-r--r--en_GY/en_GY.go25
-rw-r--r--en_HK/en_HK.go25
-rw-r--r--en_IE/en_IE.go23
-rw-r--r--en_IL/en_IL.go23
-rw-r--r--en_IM/en_IM.go25
-rw-r--r--en_IN/en_IN.go28
-rw-r--r--en_IO/en_IO.go23
-rw-r--r--en_JE/en_JE.go25
-rw-r--r--en_JM/en_JM.go23
-rw-r--r--en_KE/en_KE.go23
-rw-r--r--en_KI/en_KI.go25
-rw-r--r--en_KN/en_KN.go25
-rw-r--r--en_KY/en_KY.go25
-rw-r--r--en_LC/en_LC.go23
-rw-r--r--en_LR/en_LR.go23
-rw-r--r--en_LS/en_LS.go23
-rw-r--r--en_MG/en_MG.go25
-rw-r--r--en_MH/en_MH.go23
-rw-r--r--en_MO/en_MO.go23
-rw-r--r--en_MP/en_MP.go25
-rw-r--r--en_MS/en_MS.go23
-rw-r--r--en_MT/en_MT.go25
-rw-r--r--en_MU/en_MU.go25
-rw-r--r--en_MW/en_MW.go23
-rw-r--r--en_MY/en_MY.go23
-rw-r--r--en_NA/en_NA.go23
-rw-r--r--en_NF/en_NF.go23
-rw-r--r--en_NG/en_NG.go23
-rw-r--r--en_NL/en_NL.go23
-rw-r--r--en_NR/en_NR.go23
-rw-r--r--en_NU/en_NU.go25
-rw-r--r--en_NZ/en_NZ.go25
-rw-r--r--en_PG/en_PG.go23
-rw-r--r--en_PH/en_PH.go23
-rw-r--r--en_PK/en_PK.go23
-rw-r--r--en_PN/en_PN.go23
-rw-r--r--en_PR/en_PR.go23
-rw-r--r--en_PW/en_PW.go23
-rw-r--r--en_RW/en_RW.go23
-rw-r--r--en_SB/en_SB.go23
-rw-r--r--en_SC/en_SC.go25
-rw-r--r--en_SD/en_SD.go25
-rw-r--r--en_SE/en_SE.go18
-rw-r--r--en_SG/en_SG.go23
-rw-r--r--en_SH/en_SH.go25
-rw-r--r--en_SI/en_SI.go23
-rw-r--r--en_SL/en_SL.go23
-rw-r--r--en_SS/en_SS.go25
-rw-r--r--en_SX/en_SX.go25
-rw-r--r--en_SZ/en_SZ.go23
-rw-r--r--en_TC/en_TC.go23
-rw-r--r--en_TK/en_TK.go23
-rw-r--r--en_TO/en_TO.go23
-rw-r--r--en_TT/en_TT.go23
-rw-r--r--en_TV/en_TV.go25
-rw-r--r--en_TZ/en_TZ.go23
-rw-r--r--en_UG/en_UG.go25
-rw-r--r--en_UM/en_UM.go23
-rw-r--r--en_US/en_US.go25
-rw-r--r--en_US_POSIX/en_US_POSIX.go16
-rw-r--r--en_VC/en_VC.go23
-rw-r--r--en_VG/en_VG.go23
-rw-r--r--en_VI/en_VI.go25
-rw-r--r--en_VU/en_VU.go25
-rw-r--r--en_WS/en_WS.go25
-rw-r--r--en_ZA/en_ZA.go18
-rw-r--r--en_ZM/en_ZM.go23
-rw-r--r--en_ZW/en_ZW.go25
-rw-r--r--eo/eo.go20
-rw-r--r--eo_001/eo_001.go20
-rw-r--r--es/es.go23
-rw-r--r--es_419/es_419.go23
-rw-r--r--es_AR/es_AR.go23
-rw-r--r--es_BO/es_BO.go23
-rw-r--r--es_BR/es_BR.go23
-rw-r--r--es_CL/es_CL.go23
-rw-r--r--es_CO/es_CO.go23
-rw-r--r--es_CR/es_CR.go18
-rw-r--r--es_CU/es_CU.go23
-rw-r--r--es_DO/es_DO.go23
-rw-r--r--es_EA/es_EA.go23
-rw-r--r--es_EC/es_EC.go23
-rw-r--r--es_ES/es_ES.go23
-rw-r--r--es_GQ/es_GQ.go23
-rw-r--r--es_GT/es_GT.go23
-rw-r--r--es_HN/es_HN.go23
-rw-r--r--es_IC/es_IC.go23
-rw-r--r--es_MX/es_MX.go23
-rw-r--r--es_NI/es_NI.go23
-rw-r--r--es_PA/es_PA.go23
-rw-r--r--es_PE/es_PE.go23
-rw-r--r--es_PH/es_PH.go23
-rw-r--r--es_PR/es_PR.go23
-rw-r--r--es_PY/es_PY.go23
-rw-r--r--es_SV/es_SV.go23
-rw-r--r--es_US/es_US.go23
-rw-r--r--es_UY/es_UY.go23
-rw-r--r--es_VE/es_VE.go23
-rw-r--r--et/et.go20
-rw-r--r--et_EE/et_EE.go20
-rw-r--r--eu/eu.go23
-rw-r--r--eu_ES/eu_ES.go23
-rw-r--r--ewo/ewo.go21
-rw-r--r--ewo_CM/ewo_CM.go21
-rw-r--r--fa/fa.go15
-rw-r--r--fa_AF/fa_AF.go15
-rw-r--r--fa_IR/fa_IR.go15
-rw-r--r--ff/ff.go4
-rw-r--r--ff_CM/ff_CM.go4
-rw-r--r--ff_GN/ff_GN.go4
-rw-r--r--ff_MR/ff_MR.go4
-rw-r--r--ff_SN/ff_SN.go4
-rw-r--r--fi/fi.go20
-rw-r--r--fi_FI/fi_FI.go20
-rw-r--r--fil/fil.go23
-rw-r--r--fil_PH/fil_PH.go23
-rw-r--r--fo/fo.go25
-rw-r--r--fo_DK/fo_DK.go25
-rw-r--r--fo_FO/fo_FO.go25
-rw-r--r--fr/fr.go15
-rw-r--r--fr_BE/fr_BE.go20
-rw-r--r--fr_BF/fr_BF.go15
-rw-r--r--fr_BI/fr_BI.go15
-rw-r--r--fr_BJ/fr_BJ.go15
-rw-r--r--fr_BL/fr_BL.go15
-rw-r--r--fr_CA/fr_CA.go15
-rw-r--r--fr_CD/fr_CD.go15
-rw-r--r--fr_CF/fr_CF.go15
-rw-r--r--fr_CG/fr_CG.go15
-rw-r--r--fr_CH/fr_CH.go20
-rw-r--r--fr_CI/fr_CI.go15
-rw-r--r--fr_CM/fr_CM.go15
-rw-r--r--fr_DJ/fr_DJ.go15
-rw-r--r--fr_DZ/fr_DZ.go15
-rw-r--r--fr_FR/fr_FR.go15
-rw-r--r--fr_GA/fr_GA.go15
-rw-r--r--fr_GF/fr_GF.go15
-rw-r--r--fr_GN/fr_GN.go15
-rw-r--r--fr_GP/fr_GP.go15
-rw-r--r--fr_GQ/fr_GQ.go15
-rw-r--r--fr_HT/fr_HT.go15
-rw-r--r--fr_KM/fr_KM.go15
-rw-r--r--fr_LU/fr_LU.go20
-rw-r--r--fr_MA/fr_MA.go20
-rw-r--r--fr_MC/fr_MC.go15
-rw-r--r--fr_MF/fr_MF.go15
-rw-r--r--fr_MG/fr_MG.go15
-rw-r--r--fr_ML/fr_ML.go15
-rw-r--r--fr_MQ/fr_MQ.go15
-rw-r--r--fr_MR/fr_MR.go15
-rw-r--r--fr_MU/fr_MU.go15
-rw-r--r--fr_NC/fr_NC.go15
-rw-r--r--fr_NE/fr_NE.go15
-rw-r--r--fr_PF/fr_PF.go15
-rw-r--r--fr_PM/fr_PM.go15
-rw-r--r--fr_RE/fr_RE.go15
-rw-r--r--fr_RW/fr_RW.go15
-rw-r--r--fr_SC/fr_SC.go15
-rw-r--r--fr_SN/fr_SN.go15
-rw-r--r--fr_SY/fr_SY.go15
-rw-r--r--fr_TD/fr_TD.go15
-rw-r--r--fr_TG/fr_TG.go15
-rw-r--r--fr_TN/fr_TN.go15
-rw-r--r--fr_VU/fr_VU.go15
-rw-r--r--fr_WF/fr_WF.go15
-rw-r--r--fr_YT/fr_YT.go15
-rw-r--r--fur/fur.go23
-rw-r--r--fur_IT/fur_IT.go23
-rw-r--r--fy/fy.go23
-rw-r--r--fy_NL/fy_NL.go23
-rw-r--r--ga/ga.go23
-rw-r--r--ga_IE/ga_IE.go23
-rw-r--r--gd/gd.go15
-rw-r--r--gd_GB/gd_GB.go15
-rw-r--r--gl/gl.go23
-rw-r--r--gl_ES/gl_ES.go23
-rw-r--r--gsw/gsw.go20
-rw-r--r--gsw_CH/gsw_CH.go20
-rw-r--r--gsw_FR/gsw_FR.go20
-rw-r--r--gsw_LI/gsw_LI.go20
-rw-r--r--gu/gu.go22
-rw-r--r--gu_IN/gu_IN.go22
-rw-r--r--guz/guz.go5
-rw-r--r--guz_KE/guz_KE.go5
-rw-r--r--gv/gv.go4
-rw-r--r--gv_IM/gv_IM.go4
-rw-r--r--ha/ha.go25
-rw-r--r--ha_GH/ha_GH.go25
-rw-r--r--ha_NE/ha_NE.go25
-rw-r--r--ha_NG/ha_NG.go25
-rw-r--r--haw/haw.go4
-rw-r--r--haw_US/haw_US.go4
-rw-r--r--he/he.go25
-rw-r--r--he_IL/he_IL.go25
-rw-r--r--hi/hi.go28
-rw-r--r--hi_IN/hi_IN.go28
-rw-r--r--hr/hr.go25
-rw-r--r--hr_BA/hr_BA.go25
-rw-r--r--hr_HR/hr_HR.go25
-rw-r--r--hsb/hsb.go23
-rw-r--r--hsb_DE/hsb_DE.go23
-rw-r--r--hu/hu.go18
-rw-r--r--hu_HU/hu_HU.go18
-rw-r--r--hy/hy.go14
-rw-r--r--hy_AM/hy_AM.go14
-rw-r--r--id/id.go24
-rw-r--r--id_ID/id_ID.go24
-rw-r--r--ig/ig.go5
-rw-r--r--ig_NG/ig_NG.go5
-rw-r--r--ii/ii.go5
-rw-r--r--ii_CN/ii_CN.go5
-rw-r--r--is/is.go23
-rw-r--r--is_IS/is_IS.go23
-rw-r--r--it/it.go23
-rw-r--r--it_CH/it_CH.go23
-rw-r--r--it_IT/it_IT.go23
-rw-r--r--it_SM/it_SM.go23
-rw-r--r--ja/ja.go24
-rw-r--r--ja_JP/ja_JP.go24
-rw-r--r--jgo/jgo.go23
-rw-r--r--jgo_CM/jgo_CM.go23
-rw-r--r--jmc/jmc.go4
-rw-r--r--jmc_TZ/jmc_TZ.go4
-rw-r--r--ka/ka.go18
-rw-r--r--ka_GE/ka_GE.go18
-rw-r--r--kab/kab.go4
-rw-r--r--kab_DZ/kab_DZ.go4
-rw-r--r--kam/kam.go5
-rw-r--r--kam_KE/kam_KE.go5
-rw-r--r--kde/kde.go5
-rw-r--r--kde_TZ/kde_TZ.go5
-rw-r--r--kea/kea.go19
-rw-r--r--kea_CV/kea_CV.go19
-rw-r--r--khq/khq.go5
-rw-r--r--khq_ML/khq_ML.go5
-rw-r--r--ki/ki.go5
-rw-r--r--ki_KE/ki_KE.go5
-rw-r--r--kk/kk.go18
-rw-r--r--kk_KZ/kk_KZ.go18
-rw-r--r--kkj/kkj.go4
-rw-r--r--kkj_CM/kkj_CM.go4
-rw-r--r--kl/kl.go23
-rw-r--r--kl_GL/kl_GL.go23
-rw-r--r--kln/kln.go5
-rw-r--r--kln_KE/kln_KE.go5
-rw-r--r--km/km.go24
-rw-r--r--km_KH/km_KH.go24
-rw-r--r--kn/kn.go23
-rw-r--r--kn_IN/kn_IN.go23
-rw-r--r--ko/ko.go24
-rw-r--r--ko_KP/ko_KP.go24
-rw-r--r--ko_KR/ko_KR.go24
-rw-r--r--kok/kok.go23
-rw-r--r--kok_IN/kok_IN.go23
-rw-r--r--ks/ks.go30
-rw-r--r--ks_IN/ks_IN.go30
-rw-r--r--ksb/ksb.go4
-rw-r--r--ksb_TZ/ksb_TZ.go4
-rw-r--r--ksf/ksf.go21
-rw-r--r--ksf_CM/ksf_CM.go21
-rw-r--r--ksh/ksh.go20
-rw-r--r--ksh_DE/ksh_DE.go20
-rw-r--r--kw/kw.go4
-rw-r--r--kw_GB/kw_GB.go4
-rw-r--r--ky/ky.go18
-rw-r--r--ky_KG/ky_KG.go18
-rw-r--r--lag/lag.go4
-rw-r--r--lag_TZ/lag_TZ.go4
-rw-r--r--lb/lb.go23
-rw-r--r--lb_LU/lb_LU.go23
-rw-r--r--lg/lg.go4
-rw-r--r--lg_UG/lg_UG.go4
-rw-r--r--lkt/lkt.go5
-rw-r--r--lkt_US/lkt_US.go5
-rw-r--r--ln/ln.go23
-rw-r--r--ln_AO/ln_AO.go23
-rw-r--r--ln_CD/ln_CD.go23
-rw-r--r--ln_CF/ln_CF.go23
-rw-r--r--ln_CG/ln_CG.go23
-rw-r--r--lo/lo.go4
-rw-r--r--lo_LA/lo_LA.go4
-rw-r--r--lrc/lrc.go24
-rw-r--r--lrc_IQ/lrc_IQ.go24
-rw-r--r--lrc_IR/lrc_IR.go24
-rw-r--r--lt/lt.go20
-rw-r--r--lt_LT/lt_LT.go22
-rw-r--r--lu/lu.go26
-rw-r--r--lu_CD/lu_CD.go26
-rw-r--r--luo/luo.go5
-rw-r--r--luo_KE/luo_KE.go5
-rw-r--r--luy/luy.go5
-rw-r--r--luy_KE/luy_KE.go5
-rw-r--r--lv/lv.go22
-rw-r--r--lv_LV/lv_LV.go18
-rw-r--r--mas/mas.go4
-rw-r--r--mas_KE/mas_KE.go4
-rw-r--r--mas_TZ/mas_TZ.go4
-rw-r--r--mer/mer.go5
-rw-r--r--mer_KE/mer_KE.go5
-rw-r--r--mfe/mfe.go5
-rw-r--r--mfe_MU/mfe_MU.go5
-rw-r--r--mg/mg.go4
-rw-r--r--mg_MG/mg_MG.go4
-rw-r--r--mgh/mgh.go5
-rw-r--r--mgh_MZ/mgh_MZ.go5
-rw-r--r--mgo/mgo.go23
-rw-r--r--mgo_CM/mgo_CM.go23
-rw-r--r--mk/mk.go23
-rw-r--r--mk_MK/mk_MK.go23
-rw-r--r--ml/ml.go28
-rw-r--r--ml_IN/ml_IN.go28
-rw-r--r--mn/mn.go23
-rw-r--r--mn_MN/mn_MN.go23
-rw-r--r--mr/mr.go28
-rw-r--r--mr_IN/mr_IN.go28
-rw-r--r--mr_IN/mr_IN_test.go32
-rw-r--r--ms/ms.go23
-rw-r--r--ms_BN/ms_BN.go23
-rw-r--r--ms_MY/ms_MY.go23
-rw-r--r--ms_SG/ms_SG.go23
-rw-r--r--mt/mt.go23
-rw-r--r--mt_MT/mt_MT.go23
-rw-r--r--mua/mua.go26
-rw-r--r--mua_CM/mua_CM.go26
-rw-r--r--my/my.go24
-rw-r--r--my_MM/my_MM.go24
-rw-r--r--mzn/mzn.go5
-rw-r--r--mzn_IR/mzn_IR.go5
-rw-r--r--naq/naq.go4
-rw-r--r--naq_NA/naq_NA.go4
-rw-r--r--nb/nb.go15
-rw-r--r--nb_NO/nb_NO.go15
-rw-r--r--nb_SJ/nb_SJ.go15
-rw-r--r--nd/nd.go4
-rw-r--r--nd_ZW/nd_ZW.go4
-rw-r--r--ne/ne.go23
-rw-r--r--ne_IN/ne_IN.go23
-rw-r--r--ne_NP/ne_NP.go23
-rw-r--r--nl/nl.go15
-rw-r--r--nl_AW/nl_AW.go15
-rw-r--r--nl_BE/nl_BE.go15
-rw-r--r--nl_BQ/nl_BQ.go15
-rw-r--r--nl_CW/nl_CW.go15
-rw-r--r--nl_NL/nl_NL.go15
-rw-r--r--nl_SR/nl_SR.go15
-rw-r--r--nl_SX/nl_SX.go15
-rw-r--r--nmg/nmg.go21
-rw-r--r--nmg_CM/nmg_CM.go21
-rw-r--r--nn/nn.go20
-rw-r--r--nn_NO/nn_NO.go20
-rw-r--r--nnh/nnh.go25
-rw-r--r--nnh_CM/nnh_CM.go25
-rw-r--r--nus/nus.go26
-rw-r--r--nus_SS/nus_SS.go26
-rw-r--r--nyn/nyn.go4
-rw-r--r--nyn_UG/nyn_UG.go4
-rw-r--r--om/om.go4
-rw-r--r--om_ET/om_ET.go4
-rw-r--r--om_KE/om_KE.go4
-rw-r--r--or/or.go30
-rw-r--r--or_IN/or_IN.go30
-rw-r--r--os/os.go18
-rw-r--r--os_GE/os_GE.go18
-rw-r--r--os_RU/os_RU.go18
-rw-r--r--pa/pa.go23
-rw-r--r--pa_Arab/pa_Arab.go25
-rw-r--r--pa_Arab_PK/pa_Arab_PK.go23
-rw-r--r--pa_Guru/pa_Guru.go23
-rw-r--r--pa_Guru_IN/pa_Guru_IN.go23
-rw-r--r--pl/pl.go18
-rw-r--r--pl_PL/pl_PL.go18
-rw-r--r--prg/prg.go18
-rw-r--r--prg_001/prg_001.go18
-rw-r--r--ps/ps.go4
-rw-r--r--ps_AF/ps_AF.go4
-rw-r--r--pt/pt.go23
-rw-r--r--pt_AO/pt_AO.go23
-rw-r--r--pt_BR/pt_BR.go23
-rw-r--r--pt_CH/pt_CH.go23
-rw-r--r--pt_CV/pt_CV.go23
-rw-r--r--pt_GQ/pt_GQ.go23
-rw-r--r--pt_GW/pt_GW.go23
-rw-r--r--pt_LU/pt_LU.go23
-rw-r--r--pt_MO/pt_MO.go23
-rw-r--r--pt_MZ/pt_MZ.go23
-rw-r--r--pt_PT/pt_PT.go18
-rw-r--r--pt_ST/pt_ST.go23
-rw-r--r--pt_TL/pt_TL.go23
-rw-r--r--qu/qu.go24
-rw-r--r--qu_BO/qu_BO.go24
-rw-r--r--qu_EC/qu_EC.go24
-rw-r--r--qu_PE/qu_PE.go24
-rw-r--r--rm/rm.go20
-rw-r--r--rm_CH/rm_CH.go20
-rw-r--r--rn/rn.go26
-rw-r--r--rn_BI/rn_BI.go26
-rw-r--r--ro/ro.go23
-rw-r--r--ro_MD/ro_MD.go23
-rw-r--r--ro_RO/ro_RO.go23
-rw-r--r--rof/rof.go4
-rw-r--r--rof_TZ/rof_TZ.go4
-rw-r--r--root/root.go5
-rw-r--r--ru/ru.go18
-rw-r--r--ru_BY/ru_BY.go18
-rw-r--r--ru_KG/ru_KG.go18
-rw-r--r--ru_KZ/ru_KZ.go20
-rw-r--r--ru_MD/ru_MD.go18
-rw-r--r--ru_RU/ru_RU.go18
-rw-r--r--ru_UA/ru_UA.go20
-rw-r--r--rules.go5
-rw-r--r--rw/rw.go5
-rw-r--r--rw_RW/rw_RW.go5
-rw-r--r--rwk/rwk.go4
-rw-r--r--rwk_TZ/rwk_TZ.go4
-rw-r--r--sah/sah.go5
-rw-r--r--sah_RU/sah_RU.go5
-rw-r--r--saq/saq.go4
-rw-r--r--saq_KE/saq_KE.go4
-rw-r--r--sbp/sbp.go26
-rw-r--r--sbp_TZ/sbp_TZ.go26
-rw-r--r--se/se.go20
-rw-r--r--se_FI/se_FI.go20
-rw-r--r--se_NO/se_NO.go20
-rw-r--r--se_SE/se_SE.go20
-rw-r--r--seh/seh.go4
-rw-r--r--seh_MZ/seh_MZ.go4
-rw-r--r--ses/ses.go5
-rw-r--r--ses_ML/ses_ML.go5
-rw-r--r--sg/sg.go5
-rw-r--r--sg_CF/sg_CF.go5
-rw-r--r--shi/shi.go4
-rw-r--r--shi_Latn/shi_Latn.go4
-rw-r--r--shi_Latn_MA/shi_Latn_MA.go4
-rw-r--r--shi_Tfng/shi_Tfng.go4
-rw-r--r--shi_Tfng_MA/shi_Tfng_MA.go4
-rw-r--r--si/si.go23
-rw-r--r--si_LK/si_LK.go23
-rw-r--r--sk/sk.go18
-rw-r--r--sk_SK/sk_SK.go18
-rw-r--r--sl/sl.go23
-rw-r--r--sl_SI/sl_SI.go23
-rw-r--r--smn/smn.go4
-rw-r--r--smn_FI/smn_FI.go4
-rw-r--r--sn/sn.go4
-rw-r--r--sn_ZW/sn_ZW.go4
-rw-r--r--so/so.go4
-rw-r--r--so_DJ/so_DJ.go4
-rw-r--r--so_ET/so_ET.go4
-rw-r--r--so_KE/so_KE.go4
-rw-r--r--so_SO/so_SO.go4
-rw-r--r--sq/sq.go18
-rw-r--r--sq_AL/sq_AL.go20
-rw-r--r--sq_MK/sq_MK.go18
-rw-r--r--sq_XK/sq_XK.go18
-rw-r--r--sr/sr.go25
-rw-r--r--sr_Cyrl/sr_Cyrl.go23
-rw-r--r--sr_Cyrl_BA/sr_Cyrl_BA.go23
-rw-r--r--sr_Cyrl_ME/sr_Cyrl_ME.go23
-rw-r--r--sr_Cyrl_RS/sr_Cyrl_RS.go23
-rw-r--r--sr_Cyrl_XK/sr_Cyrl_XK.go23
-rw-r--r--sr_Latn/sr_Latn.go25
-rw-r--r--sr_Latn_BA/sr_Latn_BA.go25
-rw-r--r--sr_Latn_ME/sr_Latn_ME.go23
-rw-r--r--sr_Latn_RS/sr_Latn_RS.go25
-rw-r--r--sr_Latn_XK/sr_Latn_XK.go23
-rw-r--r--sv/sv.go15
-rw-r--r--sv_AX/sv_AX.go15
-rw-r--r--sv_FI/sv_FI.go15
-rw-r--r--sv_SE/sv_SE.go15
-rw-r--r--sw/sw.go23
-rw-r--r--sw_CD/sw_CD.go23
-rw-r--r--sw_KE/sw_KE.go23
-rw-r--r--sw_TZ/sw_TZ.go23
-rw-r--r--sw_UG/sw_UG.go23
-rw-r--r--ta/ta.go28
-rw-r--r--ta_IN/ta_IN.go28
-rw-r--r--ta_LK/ta_LK.go28
-rw-r--r--ta_MY/ta_MY.go23
-rw-r--r--ta_SG/ta_SG.go23
-rw-r--r--te/te.go28
-rw-r--r--te_IN/te_IN.go28
-rw-r--r--teo/teo.go4
-rw-r--r--teo_KE/teo_KE.go4
-rw-r--r--teo_UG/teo_UG.go4
-rw-r--r--th/th.go24
-rw-r--r--th_TH/th_TH.go24
-rw-r--r--ti/ti.go4
-rw-r--r--ti_ER/ti_ER.go4
-rw-r--r--ti_ET/ti_ET.go4
-rw-r--r--tk/tk.go18
-rw-r--r--tk_TM/tk_TM.go18
-rw-r--r--to/to.go24
-rw-r--r--to_TO/to_TO.go24
-rw-r--r--tr/tr.go23
-rw-r--r--tr_CY/tr_CY.go23
-rw-r--r--tr_TR/tr_TR.go23
-rw-r--r--twq/twq.go21
-rw-r--r--twq_NE/twq_NE.go21
-rw-r--r--tzm/tzm.go4
-rw-r--r--tzm_MA/tzm_MA.go4
-rw-r--r--ug/ug.go23
-rw-r--r--ug_CN/ug_CN.go23
-rw-r--r--uk/uk.go18
-rw-r--r--uk_UA/uk_UA.go18
-rw-r--r--ur/ur.go25
-rw-r--r--ur_IN/ur_IN.go25
-rw-r--r--ur_PK/ur_PK.go25
-rw-r--r--uz/uz.go13
-rw-r--r--uz_Arab/uz_Arab.go13
-rw-r--r--uz_Arab_AF/uz_Arab_AF.go13
-rw-r--r--uz_Cyrl/uz_Cyrl.go13
-rw-r--r--uz_Cyrl_UZ/uz_Cyrl_UZ.go13
-rw-r--r--uz_Latn/uz_Latn.go13
-rw-r--r--uz_Latn_UZ/uz_Latn_UZ.go13
-rw-r--r--vai/vai.go26
-rw-r--r--vai_Latn/vai_Latn.go26
-rw-r--r--vai_Latn_LR/vai_Latn_LR.go26
-rw-r--r--vai_Vaii/vai_Vaii.go26
-rw-r--r--vai_Vaii_LR/vai_Vaii_LR.go26
-rw-r--r--vi/vi.go23
-rw-r--r--vi_VN/vi_VN.go23
-rw-r--r--vo/vo.go4
-rw-r--r--vo_001/vo_001.go4
-rw-r--r--vun/vun.go4
-rw-r--r--vun_TZ/vun_TZ.go4
-rw-r--r--wae/wae.go4
-rw-r--r--wae_CH/wae_CH.go4
-rw-r--r--xog/xog.go4
-rw-r--r--xog_UG/xog_UG.go4
-rw-r--r--yav/yav.go21
-rw-r--r--yav_CM/yav_CM.go21
-rw-r--r--yi/yi.go4
-rw-r--r--yi_001/yi_001.go4
-rw-r--r--yo/yo.go5
-rw-r--r--yo_BJ/yo_BJ.go5
-rw-r--r--yo_NG/yo_NG.go5
-rw-r--r--yue/yue.go24
-rw-r--r--yue_HK/yue_HK.go24
-rw-r--r--zgh/zgh.go5
-rw-r--r--zgh_MA/zgh_MA.go5
-rw-r--r--zh/zh.go24
-rw-r--r--zh_Hans/zh_Hans.go24
-rw-r--r--zh_Hans_CN/zh_Hans_CN.go24
-rw-r--r--zh_Hans_HK/zh_Hans_HK.go24
-rw-r--r--zh_Hans_MO/zh_Hans_MO.go24
-rw-r--r--zh_Hans_SG/zh_Hans_SG.go24
-rw-r--r--zh_Hant/zh_Hant.go24
-rw-r--r--zh_Hant_HK/zh_Hant_HK.go24
-rw-r--r--zh_Hant_MO/zh_Hant_MO.go24
-rw-r--r--zh_Hant_TW/zh_Hant_TW.go24
-rw-r--r--zu/zu.go23
-rw-r--r--zu_ZA/zu_ZA.go23
719 files changed, 4778 insertions, 8245 deletions
diff --git a/af/af.go b/af/af.go
index f1c05cf6..bfae3971 100644
--- a/af/af.go
+++ b/af/af.go
@@ -76,32 +76,23 @@ func (af *af) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (af *af) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(af.decimal) + len(af.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(af.decimal) - 1; j >= 0; j-- {
- b = append(b, af.decimal[j])
- }
-
+ b = append(b, af.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(af.group) - 1; j >= 0; j-- {
b = append(b, af.group[j])
}
@@ -115,11 +106,14 @@ func (af *af) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, af.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/af_NA/af_NA.go b/af_NA/af_NA.go
index ab448ce9..e468bdf5 100644
--- a/af_NA/af_NA.go
+++ b/af_NA/af_NA.go
@@ -76,32 +76,23 @@ func (af *af_NA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (af *af_NA) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(af.decimal) + len(af.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(af.decimal) - 1; j >= 0; j-- {
- b = append(b, af.decimal[j])
- }
-
+ b = append(b, af.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(af.group) - 1; j >= 0; j-- {
b = append(b, af.group[j])
}
@@ -115,11 +106,14 @@ func (af *af_NA) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, af.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/af_ZA/af_ZA.go b/af_ZA/af_ZA.go
index e0f98f66..6c13d896 100644
--- a/af_ZA/af_ZA.go
+++ b/af_ZA/af_ZA.go
@@ -76,32 +76,23 @@ func (af *af_ZA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (af *af_ZA) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(af.decimal) + len(af.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(af.decimal) - 1; j >= 0; j-- {
- b = append(b, af.decimal[j])
- }
-
+ b = append(b, af.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(af.group) - 1; j >= 0; j-- {
b = append(b, af.group[j])
}
@@ -115,11 +106,14 @@ func (af *af_ZA) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, af.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/agq/agq.go b/agq/agq.go
index feaec68b..85e30c9a 100644
--- a/agq/agq.go
+++ b/agq/agq.go
@@ -1,6 +1,7 @@
package agq
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,32 +69,23 @@ func (agq *agq) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (agq *agq) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(agq.decimal) + len(agq.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(agq.decimal) - 1; j >= 0; j-- {
- b = append(b, agq.decimal[j])
- }
-
+ b = append(b, agq.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(agq.group) - 1; j >= 0; j-- {
b = append(b, agq.group[j])
}
@@ -107,11 +99,16 @@ func (agq *agq) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(agq.minus) - 1; j >= 0; j-- {
+ b = append(b, agq.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/agq_CM/agq_CM.go b/agq_CM/agq_CM.go
index 2c078b35..5e14cda8 100644
--- a/agq_CM/agq_CM.go
+++ b/agq_CM/agq_CM.go
@@ -1,6 +1,7 @@
package agq_CM
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,32 +69,23 @@ func (agq *agq_CM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (agq *agq_CM) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(agq.decimal) + len(agq.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(agq.decimal) - 1; j >= 0; j-- {
- b = append(b, agq.decimal[j])
- }
-
+ b = append(b, agq.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(agq.group) - 1; j >= 0; j-- {
b = append(b, agq.group[j])
}
@@ -107,11 +99,16 @@ func (agq *agq_CM) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(agq.minus) - 1; j >= 0; j-- {
+ b = append(b, agq.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ak/ak.go b/ak/ak.go
index 93e70a40..37ba443b 100644
--- a/ak/ak.go
+++ b/ak/ak.go
@@ -76,8 +76,6 @@ func (ak *ak) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (ak *ak) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/ak_GH/ak_GH.go b/ak_GH/ak_GH.go
index 4907b1e0..abfdd13d 100644
--- a/ak_GH/ak_GH.go
+++ b/ak_GH/ak_GH.go
@@ -76,8 +76,6 @@ func (ak *ak_GH) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ak *ak_GH) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/am/am.go b/am/am.go
index 12cde443..52cadc2b 100644
--- a/am/am.go
+++ b/am/am.go
@@ -88,36 +88,24 @@ func (am *am) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (am *am) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(am.decimal) + len(am.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(am.decimal) - 1; j >= 0; j-- {
- b = append(b, am.decimal[j])
- }
-
+ b = append(b, am.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(am.group) - 1; j >= 0; j-- {
- b = append(b, am.group[j])
- }
-
+ b = append(b, am.group[0])
count = 1
} else {
count++
@@ -127,11 +115,14 @@ func (am *am) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, am.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/am_ET/am_ET.go b/am_ET/am_ET.go
index a773b050..6e514cef 100644
--- a/am_ET/am_ET.go
+++ b/am_ET/am_ET.go
@@ -88,36 +88,24 @@ func (am *am_ET) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (am *am_ET) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(am.decimal) + len(am.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(am.decimal) - 1; j >= 0; j-- {
- b = append(b, am.decimal[j])
- }
-
+ b = append(b, am.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(am.group) - 1; j >= 0; j-- {
- b = append(b, am.group[j])
- }
-
+ b = append(b, am.group[0])
count = 1
} else {
count++
@@ -127,11 +115,14 @@ func (am *am_ET) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, am.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ar/ar.go b/ar/ar.go
index 4ddf10f1..259c8204 100644
--- a/ar/ar.go
+++ b/ar/ar.go
@@ -30,7 +30,7 @@ func New() locales.Translator {
minus: []byte{0xe2, 0x80, 0x8f, 0x2d},
percent: []byte{0xd9, 0xaa},
perMille: []byte{0xd8, 0x89},
- currencies: [][]uint8{{0x41, 0x44, 0x50}, {0xd8, 0xaf, 0x2e, 0xd8, 0xa5, 0x2e, 0xe2, 0x80, 0x8f}, {0x41, 0x46, 0x41}, {0x41, 0x46, 0x4e}, {0x41, 0x4c, 0x4b}, {0x41, 0x4c, 0x4c}, {0x41, 0x4d, 0x44}, {0x41, 0x4e, 0x47}, {0x41, 0x4f, 0x41}, {0x41, 0x4f, 0x4b}, {0x41, 0x4f, 0x4e}, {0x41, 0x4f, 0x52}, {0x41, 0x52, 0x41}, {0x41, 0x52, 0x4c}, {0x41, 0x52, 0x4d}, {0x41, 0x52, 0x50}, {0x41, 0x52, 0x53}, {0x41, 0x54, 0x53}, {0x41, 0x55, 0x24}, {0x41, 0x57, 0x47}, {0x41, 0x5a, 0x4d}, {0x41, 0x5a, 0x4e}, {0x42, 0x41, 0x44}, {0x42, 0x41, 0x4d}, {0x42, 0x41, 0x4e}, {0x42, 0x42, 0x44}, {0x42, 0x44, 0x54}, {0x42, 0x45, 0x43}, {0x42, 0x45, 0x46}, {0x42, 0x45, 0x4c}, {0x42, 0x47, 0x4c}, {0x42, 0x47, 0x4d}, {0x42, 0x47, 0x4e}, {0x42, 0x47, 0x4f}, {0xd8, 0xaf, 0x2e, 0xd8, 0xa8, 0x2e, 0xe2, 0x80, 0x8f}, {0x42, 0x49, 0x46}, {0x42, 0x4d, 0x44}, {0x42, 0x4e, 0x44}, {0x42, 0x4f, 0x42}, {0x42, 0x4f, 0x4c}, {0x42, 0x4f, 0x50}, {0x42, 0x4f, 0x56}, {0x42, 0x52, 0x42}, {0x42, 0x52, 0x43}, {0x42, 0x52, 0x45}, {0x52, 0x24}, {0x42, 0x52, 0x4e}, {0x42, 0x52, 0x52}, {0x42, 0x52, 0x5a}, {0x42, 0x53, 0x44}, {0x42, 0x54, 0x4e}, {0x42, 0x55, 0x4b}, {0x42, 0x57, 0x50}, {0x42, 0x59, 0x42}, {0x42, 0x59, 0x52}, {0x42, 0x5a, 0x44}, {0x43, 0x41, 0x24}, {0x43, 0x44, 0x46}, {0x43, 0x48, 0x45}, {0x43, 0x48, 0x46}, {0x43, 0x48, 0x57}, {0x43, 0x4c, 0x45}, {0x43, 0x4c, 0x46}, {0x43, 0x4c, 0x50}, {0x43, 0x4e, 0x58}, {0x43, 0x4e, 0xc2, 0xa5}, {0x43, 0x4f, 0x50}, {0x43, 0x4f, 0x55}, {0x43, 0x52, 0x43}, {0x43, 0x53, 0x44}, {0x43, 0x53, 0x4b}, {0x43, 0x55, 0x43}, {0x43, 0x55, 0x50}, {0x43, 0x56, 0x45}, {0x43, 0x59, 0x50}, {0x43, 0x5a, 0x4b}, {0x44, 0x44, 0x4d}, {0x44, 0x45, 0x4d}, {0x44, 0x4a, 0x46}, {0x44, 0x4b, 0x4b}, {0x44, 0x4f, 0x50}, {0xd8, 0xaf, 0x2e, 0xd8, 0xac, 0x2e, 0xe2, 0x80, 0x8f}, {0x45, 0x43, 0x53}, {0x45, 0x43, 0x56}, {0x45, 0x45, 0x4b}, {0xd8, 0xac, 0x2e, 0xd9, 0x85, 0x2e, 0xe2, 0x80, 0x8f}, {0x45, 0x52, 0x4e}, {0x45, 0x53, 0x41}, {0x45, 0x53, 0x42}, {0x45, 0x53, 0x50}, {0x45, 0x54, 0x42}, {0xe2, 0x82, 0xac}, {0x46, 0x49, 0x4d}, {0x46, 0x4a, 0x44}, {0x46, 0x4b, 0x50}, {0x46, 0x52, 0x46}, {0xc2, 0xa3}, {0x47, 0x45, 0x4b}, {0x47, 0x45, 0x4c}, {0x47, 0x48, 0x43}, {0x47, 0x48, 0x53}, {0x47, 0x49, 0x50}, {0x47, 0x4d, 0x44}, {0x47, 0x4e, 0x46}, {0x47, 0x4e, 0x53}, {0x47, 0x51, 0x45}, {0x47, 0x52, 0x44}, {0x47, 0x54, 0x51}, {0x47, 0x57, 0x45}, {0x47, 0x57, 0x50}, {0x47, 0x59, 0x44}, {0x48, 0x4b, 0x24}, {0x48, 0x4e, 0x4c}, {0x48, 0x52, 0x44}, {0x48, 0x52, 0x4b}, {0x48, 0x54, 0x47}, {0x48, 0x55, 0x46}, {0xd8, 0xb1, 0x2e, 0xd8, 0xa5, 0xd9, 0x86, 0x2e}, {0x49, 0x45, 0x50}, {0x49, 0x4c, 0x50}, {0x49, 0x4c, 0x52}, {0xe2, 0x82, 0xaa}, {0xe2, 0x82, 0xb9}, {0xd8, 0xaf, 0x2e, 0xd8, 0xb9, 0x2e, 0xe2, 0x80, 0x8f}, {0xd8, 0xb1, 0x2e, 0xd8, 0xa5, 0x2e}, {0x49, 0x53, 0x4a}, {0x49, 0x53, 0x4b}, {0x49, 0x54, 0x4c}, {0x4a, 0x4d, 0x44}, {0xd8, 0xaf, 0x2e, 0xd8, 0xa3, 0x2e, 0xe2, 0x80, 0x8f}, {0x4a, 0x50, 0xc2, 0xa5}, {0x4b, 0x45, 0x53}, {0x4b, 0x47, 0x53}, {0x4b, 0x48, 0x52}, {0xd9, 0x81, 0x2e, 0xd8, 0xac, 0x2e, 0xd9, 0x82, 0x2e, 0xe2, 0x80, 0x8f}, {0x4b, 0x50, 0x57}, {0x4b, 0x52, 0x48}, {0x4b, 0x52, 0x4f}, {0xe2, 0x82, 0xa9}, {0xd8, 0xaf, 0x2e, 0xd9, 0x83, 0x2e, 0xe2, 0x80, 0x8f}, {0x4b, 0x59, 0x44}, {0x4b, 0x5a, 0x54}, {0x4c, 0x41, 0x4b}, {0xd9, 0x84, 0x2e, 0xd9, 0x84, 0x2e, 0xe2, 0x80, 0x8f}, {0x4c, 0x4b, 0x52}, {0x4c, 0x52, 0x44}, {0x4c, 0x53, 0x4c}, {0x4c, 0x54, 0x4c}, {0x4c, 0x54, 0x54}, {0x4c, 0x55, 0x43}, {0x4c, 0x55, 0x46}, {0x4c, 0x55, 0x4c}, {0x4c, 0x56, 0x4c}, {0x4c, 0x56, 0x52}, {0xd8, 0xaf, 0x2e, 0xd9, 0x84, 0x2e, 0xe2, 0x80, 0x8f}, {0xd8, 0xaf, 0x2e, 0xd9, 0x85, 0x2e, 0xe2, 0x80, 0x8f}, {0x4d, 0x41, 0x46}, {0x4d, 0x43, 0x46}, {0x4d, 0x44, 0x43}, {0x4d, 0x44, 0x4c}, {0x4d, 0x47, 0x41}, {0x4d, 0x47, 0x46}, {0x4d, 0x4b, 0x44}, {0x4d, 0x4b, 0x4e}, {0x4d, 0x4c, 0x46}, {0x4d, 0x4d, 0x4b}, {0x4d, 0x4e, 0x54}, {0x4d, 0x4f, 0x50}, {0xd8, 0xa3, 0x2e, 0xd9, 0x85, 0x2e, 0xe2, 0x80, 0x8f}, {0x4d, 0x54, 0x4c}, {0x4d, 0x54, 0x50}, {0x4d, 0x55, 0x52}, {0x4d, 0x56, 0x50}, {0x4d, 0x56, 0x52}, {0x4d, 0x57, 0x4b}, {0x4d, 0x58, 0x24}, {0x4d, 0x58, 0x50}, {0x4d, 0x58, 0x56}, {0x4d, 0x59, 0x52}, {0x4d, 0x5a, 0x45}, {0x4d, 0x5a, 0x4d}, {0x4d, 0x5a, 0x4e}, {0x4e, 0x41, 0x44}, {0x4e, 0x47, 0x4e}, {0x4e, 0x49, 0x43}, {0x4e, 0x49, 0x4f}, {0x4e, 0x4c, 0x47}, {0x4e, 0x4f, 0x4b}, {0x4e, 0x50, 0x52}, {0x4e, 0x5a, 0x24}, {0xd8, 0xb1, 0x2e, 0xd8, 0xb9, 0x2e, 0xe2, 0x80, 0x8f}, {0x50, 0x41, 0x42}, {0x50, 0x45, 0x49}, {0x50, 0x45, 0x4e}, {0x50, 0x45, 0x53}, {0x50, 0x47, 0x4b}, {0x50, 0x48, 0x50}, {0xd8, 0xb1, 0x2e, 0xd8, 0xa8, 0x2e}, {0x50, 0x4c, 0x4e}, {0x50, 0x4c, 0x5a}, {0x50, 0x54, 0x45}, {0x50, 0x59, 0x47}, {0xd8, 0xb1, 0x2e, 0xd9, 0x82, 0x2e, 0xe2, 0x80, 0x8f}, {0x52, 0x48, 0x44}, {0x52, 0x4f, 0x4c}, {0x52, 0x4f, 0x4e}, {0x52, 0x53, 0x44}, {0x52, 0x55, 0x42}, {0x52, 0x55, 0x52}, {0x52, 0x57, 0x46}, {0xd8, 0xb1, 0x2e, 0xd8, 0xb3, 0x2e, 0xe2, 0x80, 0x8f}, {0x53, 0x42, 0x44}, {0x53, 0x43, 0x52}, {0xd8, 0xaf, 0x2e, 0xd8, 0xb3, 0x2e, 0xe2, 0x80, 0x8f}, {0xd8, 0xac, 0x2e, 0xd8, 0xb3, 0x2e}, {0x53, 0x44, 0x50}, {0x53, 0x45, 0x4b}, {0x53, 0x47, 0x44}, {0x53, 0x48, 0x50}, {0x53, 0x49, 0x54}, {0x53, 0x4b, 0x4b}, {0x53, 0x4c, 0x4c}, {0x53, 0x4f, 0x53}, {0x53, 0x52, 0x44}, {0x53, 0x52, 0x47}, {0xd8, 0xac, 0x2e, 0xd8, 0xac, 0x2e, 0xd8, 0xb3, 0x2e}, {0x53, 0x54, 0x44}, {0x53, 0x55, 0x52}, {0x53, 0x56, 0x43}, {0xd9, 0x84, 0x2e, 0xd8, 0xb3, 0x2e, 0xe2, 0x80, 0x8f}, {0x53, 0x5a, 0x4c}, {0xe0, 0xb8, 0xbf}, {0x54, 0x4a, 0x52}, {0x54, 0x4a, 0x53}, {0x54, 0x4d, 0x4d}, {0x54, 0x4d, 0x54}, {0xd8, 0xaf, 0x2e, 0xd8, 0xaa, 0x2e, 0xe2, 0x80, 0x8f}, {0x54, 0x4f, 0x50}, {0x54, 0x50, 0x45}, {0x54, 0x52, 0x4c}, {0xd9, 0x84, 0x2e, 0xd8, 0xaa, 0x2e}, {0x54, 0x54, 0x44}, {0x4e, 0x54, 0x24}, {0x54, 0x5a, 0x53}, {0x55, 0x41, 0x48}, {0x55, 0x41, 0x4b}, {0x55, 0x47, 0x53}, {0x55, 0x47, 0x58}, {0x55, 0x53, 0x24}, {0x55, 0x53, 0x4e}, {0x55, 0x53, 0x53}, {0x55, 0x59, 0x49}, {0x55, 0x59, 0x50}, {0x55, 0x59, 0x55}, {0x55, 0x5a, 0x53}, {0x56, 0x45, 0x42}, {0x56, 0x45, 0x46}, {0xe2, 0x82, 0xab}, {0x56, 0x4e, 0x4e}, {0x56, 0x55, 0x56}, {0x57, 0x53, 0x54}, {0x46, 0x43, 0x46, 0x41}, {0x58, 0x41, 0x47}, {0x58, 0x41, 0x55}, {0x58, 0x42, 0x41}, {0x58, 0x42, 0x42}, {0x58, 0x42, 0x43}, {0x58, 0x42, 0x44}, {0x45, 0x43, 0x24}, {0x58, 0x44, 0x52}, {0x58, 0x45, 0x55}, {0x58, 0x46, 0x4f}, {0x58, 0x46, 0x55}, {0x43, 0x46, 0x41}, {0x58, 0x50, 0x44}, {0x43, 0x46, 0x50, 0x46}, {0x58, 0x50, 0x54}, {0x58, 0x52, 0x45}, {0x58, 0x53, 0x55}, {0x58, 0x54, 0x53}, {0x58, 0x55, 0x41}, {0x2a, 0x2a, 0x2a}, {0x59, 0x44, 0x44}, {0xd8, 0xb1, 0x2e, 0xd9, 0x8a, 0x2e, 0xe2, 0x80, 0x8f}, {0x59, 0x55, 0x44}, {0x59, 0x55, 0x4d}, {0x59, 0x55, 0x4e}, {0x59, 0x55, 0x52}, {0x5a, 0x41, 0x4c}, {0x5a, 0x41, 0x52}, {0x5a, 0x4d, 0x4b}, {0x5a, 0x4d, 0x57}, {0x5a, 0x52, 0x4e}, {0x5a, 0x52, 0x5a}, {0x5a, 0x57, 0x44}, {0x5a, 0x57, 0x4c}, {0x5a, 0x57, 0x52}},
+ currencies: [][]uint8{[]uint8{0x41, 0x44, 0x50}, []uint8{0xd8, 0xaf, 0x2e, 0xd8, 0xa5, 0x2e, 0xe2, 0x80, 0x8f}, []uint8{0x41, 0x46, 0x41}, []uint8{0x41, 0x46, 0x4e}, []uint8{0x41, 0x4c, 0x4b}, []uint8{0x41, 0x4c, 0x4c}, []uint8{0x41, 0x4d, 0x44}, []uint8{0x41, 0x4e, 0x47}, []uint8{0x41, 0x4f, 0x41}, []uint8{0x41, 0x4f, 0x4b}, []uint8{0x41, 0x4f, 0x4e}, []uint8{0x41, 0x4f, 0x52}, []uint8{0x41, 0x52, 0x41}, []uint8{0x41, 0x52, 0x4c}, []uint8{0x41, 0x52, 0x4d}, []uint8{0x41, 0x52, 0x50}, []uint8{0x41, 0x52, 0x53}, []uint8{0x41, 0x54, 0x53}, []uint8{0x41, 0x55, 0x24}, []uint8{0x41, 0x57, 0x47}, []uint8{0x41, 0x5a, 0x4d}, []uint8{0x41, 0x5a, 0x4e}, []uint8{0x42, 0x41, 0x44}, []uint8{0x42, 0x41, 0x4d}, []uint8{0x42, 0x41, 0x4e}, []uint8{0x42, 0x42, 0x44}, []uint8{0x42, 0x44, 0x54}, []uint8{0x42, 0x45, 0x43}, []uint8{0x42, 0x45, 0x46}, []uint8{0x42, 0x45, 0x4c}, []uint8{0x42, 0x47, 0x4c}, []uint8{0x42, 0x47, 0x4d}, []uint8{0x42, 0x47, 0x4e}, []uint8{0x42, 0x47, 0x4f}, []uint8{0xd8, 0xaf, 0x2e, 0xd8, 0xa8, 0x2e, 0xe2, 0x80, 0x8f}, []uint8{0x42, 0x49, 0x46}, []uint8{0x42, 0x4d, 0x44}, []uint8{0x42, 0x4e, 0x44}, []uint8{0x42, 0x4f, 0x42}, []uint8{0x42, 0x4f, 0x4c}, []uint8{0x42, 0x4f, 0x50}, []uint8{0x42, 0x4f, 0x56}, []uint8{0x42, 0x52, 0x42}, []uint8{0x42, 0x52, 0x43}, []uint8{0x42, 0x52, 0x45}, []uint8{0x52, 0x24}, []uint8{0x42, 0x52, 0x4e}, []uint8{0x42, 0x52, 0x52}, []uint8{0x42, 0x52, 0x5a}, []uint8{0x42, 0x53, 0x44}, []uint8{0x42, 0x54, 0x4e}, []uint8{0x42, 0x55, 0x4b}, []uint8{0x42, 0x57, 0x50}, []uint8{0x42, 0x59, 0x42}, []uint8{0x42, 0x59, 0x52}, []uint8{0x42, 0x5a, 0x44}, []uint8{0x43, 0x41, 0x24}, []uint8{0x43, 0x44, 0x46}, []uint8{0x43, 0x48, 0x45}, []uint8{0x43, 0x48, 0x46}, []uint8{0x43, 0x48, 0x57}, []uint8{0x43, 0x4c, 0x45}, []uint8{0x43, 0x4c, 0x46}, []uint8{0x43, 0x4c, 0x50}, []uint8{0x43, 0x4e, 0x58}, []uint8{0x43, 0x4e, 0xc2, 0xa5}, []uint8{0x43, 0x4f, 0x50}, []uint8{0x43, 0x4f, 0x55}, []uint8{0x43, 0x52, 0x43}, []uint8{0x43, 0x53, 0x44}, []uint8{0x43, 0x53, 0x4b}, []uint8{0x43, 0x55, 0x43}, []uint8{0x43, 0x55, 0x50}, []uint8{0x43, 0x56, 0x45}, []uint8{0x43, 0x59, 0x50}, []uint8{0x43, 0x5a, 0x4b}, []uint8{0x44, 0x44, 0x4d}, []uint8{0x44, 0x45, 0x4d}, []uint8{0x44, 0x4a, 0x46}, []uint8{0x44, 0x4b, 0x4b}, []uint8{0x44, 0x4f, 0x50}, []uint8{0xd8, 0xaf, 0x2e, 0xd8, 0xac, 0x2e, 0xe2, 0x80, 0x8f}, []uint8{0x45, 0x43, 0x53}, []uint8{0x45, 0x43, 0x56}, []uint8{0x45, 0x45, 0x4b}, []uint8{0xd8, 0xac, 0x2e, 0xd9, 0x85, 0x2e, 0xe2, 0x80, 0x8f}, []uint8{0x45, 0x52, 0x4e}, []uint8{0x45, 0x53, 0x41}, []uint8{0x45, 0x53, 0x42}, []uint8{0x45, 0x53, 0x50}, []uint8{0x45, 0x54, 0x42}, []uint8{0xe2, 0x82, 0xac}, []uint8{0x46, 0x49, 0x4d}, []uint8{0x46, 0x4a, 0x44}, []uint8{0x46, 0x4b, 0x50}, []uint8{0x46, 0x52, 0x46}, []uint8{0xc2, 0xa3}, []uint8{0x47, 0x45, 0x4b}, []uint8{0x47, 0x45, 0x4c}, []uint8{0x47, 0x48, 0x43}, []uint8{0x47, 0x48, 0x53}, []uint8{0x47, 0x49, 0x50}, []uint8{0x47, 0x4d, 0x44}, []uint8{0x47, 0x4e, 0x46}, []uint8{0x47, 0x4e, 0x53}, []uint8{0x47, 0x51, 0x45}, []uint8{0x47, 0x52, 0x44}, []uint8{0x47, 0x54, 0x51}, []uint8{0x47, 0x57, 0x45}, []uint8{0x47, 0x57, 0x50}, []uint8{0x47, 0x59, 0x44}, []uint8{0x48, 0x4b, 0x24}, []uint8{0x48, 0x4e, 0x4c}, []uint8{0x48, 0x52, 0x44}, []uint8{0x48, 0x52, 0x4b}, []uint8{0x48, 0x54, 0x47}, []uint8{0x48, 0x55, 0x46}, []uint8{0xd8, 0xb1, 0x2e, 0xd8, 0xa5, 0xd9, 0x86, 0x2e}, []uint8{0x49, 0x45, 0x50}, []uint8{0x49, 0x4c, 0x50}, []uint8{0x49, 0x4c, 0x52}, []uint8{0xe2, 0x82, 0xaa}, []uint8{0xe2, 0x82, 0xb9}, []uint8{0xd8, 0xaf, 0x2e, 0xd8, 0xb9, 0x2e, 0xe2, 0x80, 0x8f}, []uint8{0xd8, 0xb1, 0x2e, 0xd8, 0xa5, 0x2e}, []uint8{0x49, 0x53, 0x4a}, []uint8{0x49, 0x53, 0x4b}, []uint8{0x49, 0x54, 0x4c}, []uint8{0x4a, 0x4d, 0x44}, []uint8{0xd8, 0xaf, 0x2e, 0xd8, 0xa3, 0x2e, 0xe2, 0x80, 0x8f}, []uint8{0x4a, 0x50, 0xc2, 0xa5}, []uint8{0x4b, 0x45, 0x53}, []uint8{0x4b, 0x47, 0x53}, []uint8{0x4b, 0x48, 0x52}, []uint8{0xd9, 0x81, 0x2e, 0xd8, 0xac, 0x2e, 0xd9, 0x82, 0x2e, 0xe2, 0x80, 0x8f}, []uint8{0x4b, 0x50, 0x57}, []uint8{0x4b, 0x52, 0x48}, []uint8{0x4b, 0x52, 0x4f}, []uint8{0xe2, 0x82, 0xa9}, []uint8{0xd8, 0xaf, 0x2e, 0xd9, 0x83, 0x2e, 0xe2, 0x80, 0x8f}, []uint8{0x4b, 0x59, 0x44}, []uint8{0x4b, 0x5a, 0x54}, []uint8{0x4c, 0x41, 0x4b}, []uint8{0xd9, 0x84, 0x2e, 0xd9, 0x84, 0x2e, 0xe2, 0x80, 0x8f}, []uint8{0x4c, 0x4b, 0x52}, []uint8{0x4c, 0x52, 0x44}, []uint8{0x4c, 0x53, 0x4c}, []uint8{0x4c, 0x54, 0x4c}, []uint8{0x4c, 0x54, 0x54}, []uint8{0x4c, 0x55, 0x43}, []uint8{0x4c, 0x55, 0x46}, []uint8{0x4c, 0x55, 0x4c}, []uint8{0x4c, 0x56, 0x4c}, []uint8{0x4c, 0x56, 0x52}, []uint8{0xd8, 0xaf, 0x2e, 0xd9, 0x84, 0x2e, 0xe2, 0x80, 0x8f}, []uint8{0xd8, 0xaf, 0x2e, 0xd9, 0x85, 0x2e, 0xe2, 0x80, 0x8f}, []uint8{0x4d, 0x41, 0x46}, []uint8{0x4d, 0x43, 0x46}, []uint8{0x4d, 0x44, 0x43}, []uint8{0x4d, 0x44, 0x4c}, []uint8{0x4d, 0x47, 0x41}, []uint8{0x4d, 0x47, 0x46}, []uint8{0x4d, 0x4b, 0x44}, []uint8{0x4d, 0x4b, 0x4e}, []uint8{0x4d, 0x4c, 0x46}, []uint8{0x4d, 0x4d, 0x4b}, []uint8{0x4d, 0x4e, 0x54}, []uint8{0x4d, 0x4f, 0x50}, []uint8{0xd8, 0xa3, 0x2e, 0xd9, 0x85, 0x2e, 0xe2, 0x80, 0x8f}, []uint8{0x4d, 0x54, 0x4c}, []uint8{0x4d, 0x54, 0x50}, []uint8{0x4d, 0x55, 0x52}, []uint8{0x4d, 0x56, 0x50}, []uint8{0x4d, 0x56, 0x52}, []uint8{0x4d, 0x57, 0x4b}, []uint8{0x4d, 0x58, 0x24}, []uint8{0x4d, 0x58, 0x50}, []uint8{0x4d, 0x58, 0x56}, []uint8{0x4d, 0x59, 0x52}, []uint8{0x4d, 0x5a, 0x45}, []uint8{0x4d, 0x5a, 0x4d}, []uint8{0x4d, 0x5a, 0x4e}, []uint8{0x4e, 0x41, 0x44}, []uint8{0x4e, 0x47, 0x4e}, []uint8{0x4e, 0x49, 0x43}, []uint8{0x4e, 0x49, 0x4f}, []uint8{0x4e, 0x4c, 0x47}, []uint8{0x4e, 0x4f, 0x4b}, []uint8{0x4e, 0x50, 0x52}, []uint8{0x4e, 0x5a, 0x24}, []uint8{0xd8, 0xb1, 0x2e, 0xd8, 0xb9, 0x2e, 0xe2, 0x80, 0x8f}, []uint8{0x50, 0x41, 0x42}, []uint8{0x50, 0x45, 0x49}, []uint8{0x50, 0x45, 0x4e}, []uint8{0x50, 0x45, 0x53}, []uint8{0x50, 0x47, 0x4b}, []uint8{0x50, 0x48, 0x50}, []uint8{0xd8, 0xb1, 0x2e, 0xd8, 0xa8, 0x2e}, []uint8{0x50, 0x4c, 0x4e}, []uint8{0x50, 0x4c, 0x5a}, []uint8{0x50, 0x54, 0x45}, []uint8{0x50, 0x59, 0x47}, []uint8{0xd8, 0xb1, 0x2e, 0xd9, 0x82, 0x2e, 0xe2, 0x80, 0x8f}, []uint8{0x52, 0x48, 0x44}, []uint8{0x52, 0x4f, 0x4c}, []uint8{0x52, 0x4f, 0x4e}, []uint8{0x52, 0x53, 0x44}, []uint8{0x52, 0x55, 0x42}, []uint8{0x52, 0x55, 0x52}, []uint8{0x52, 0x57, 0x46}, []uint8{0xd8, 0xb1, 0x2e, 0xd8, 0xb3, 0x2e, 0xe2, 0x80, 0x8f}, []uint8{0x53, 0x42, 0x44}, []uint8{0x53, 0x43, 0x52}, []uint8{0xd8, 0xaf, 0x2e, 0xd8, 0xb3, 0x2e, 0xe2, 0x80, 0x8f}, []uint8{0xd8, 0xac, 0x2e, 0xd8, 0xb3, 0x2e}, []uint8{0x53, 0x44, 0x50}, []uint8{0x53, 0x45, 0x4b}, []uint8{0x53, 0x47, 0x44}, []uint8{0x53, 0x48, 0x50}, []uint8{0x53, 0x49, 0x54}, []uint8{0x53, 0x4b, 0x4b}, []uint8{0x53, 0x4c, 0x4c}, []uint8{0x53, 0x4f, 0x53}, []uint8{0x53, 0x52, 0x44}, []uint8{0x53, 0x52, 0x47}, []uint8{0xd8, 0xac, 0x2e, 0xd8, 0xac, 0x2e, 0xd8, 0xb3, 0x2e}, []uint8{0x53, 0x54, 0x44}, []uint8{0x53, 0x55, 0x52}, []uint8{0x53, 0x56, 0x43}, []uint8{0xd9, 0x84, 0x2e, 0xd8, 0xb3, 0x2e, 0xe2, 0x80, 0x8f}, []uint8{0x53, 0x5a, 0x4c}, []uint8{0xe0, 0xb8, 0xbf}, []uint8{0x54, 0x4a, 0x52}, []uint8{0x54, 0x4a, 0x53}, []uint8{0x54, 0x4d, 0x4d}, []uint8{0x54, 0x4d, 0x54}, []uint8{0xd8, 0xaf, 0x2e, 0xd8, 0xaa, 0x2e, 0xe2, 0x80, 0x8f}, []uint8{0x54, 0x4f, 0x50}, []uint8{0x54, 0x50, 0x45}, []uint8{0x54, 0x52, 0x4c}, []uint8{0xd9, 0x84, 0x2e, 0xd8, 0xaa, 0x2e}, []uint8{0x54, 0x54, 0x44}, []uint8{0x4e, 0x54, 0x24}, []uint8{0x54, 0x5a, 0x53}, []uint8{0x55, 0x41, 0x48}, []uint8{0x55, 0x41, 0x4b}, []uint8{0x55, 0x47, 0x53}, []uint8{0x55, 0x47, 0x58}, []uint8{0x55, 0x53, 0x24}, []uint8{0x55, 0x53, 0x4e}, []uint8{0x55, 0x53, 0x53}, []uint8{0x55, 0x59, 0x49}, []uint8{0x55, 0x59, 0x50}, []uint8{0x55, 0x59, 0x55}, []uint8{0x55, 0x5a, 0x53}, []uint8{0x56, 0x45, 0x42}, []uint8{0x56, 0x45, 0x46}, []uint8{0xe2, 0x82, 0xab}, []uint8{0x56, 0x4e, 0x4e}, []uint8{0x56, 0x55, 0x56}, []uint8{0x57, 0x53, 0x54}, []uint8{0x46, 0x43, 0x46, 0x41}, []uint8{0x58, 0x41, 0x47}, []uint8{0x58, 0x41, 0x55}, []uint8{0x58, 0x42, 0x41}, []uint8{0x58, 0x42, 0x42}, []uint8{0x58, 0x42, 0x43}, []uint8{0x58, 0x42, 0x44}, []uint8{0x45, 0x43, 0x24}, []uint8{0x58, 0x44, 0x52}, []uint8{0x58, 0x45, 0x55}, []uint8{0x58, 0x46, 0x4f}, []uint8{0x58, 0x46, 0x55}, []uint8{0x43, 0x46, 0x41}, []uint8{0x58, 0x50, 0x44}, []uint8{0x43, 0x46, 0x50, 0x46}, []uint8{0x58, 0x50, 0x54}, []uint8{0x58, 0x52, 0x45}, []uint8{0x58, 0x53, 0x55}, []uint8{0x58, 0x54, 0x53}, []uint8{0x58, 0x55, 0x41}, []uint8{0x2a, 0x2a, 0x2a}, []uint8{0x59, 0x44, 0x44}, []uint8{0xd8, 0xb1, 0x2e, 0xd9, 0x8a, 0x2e, 0xe2, 0x80, 0x8f}, []uint8{0x59, 0x55, 0x44}, []uint8{0x59, 0x55, 0x4d}, []uint8{0x59, 0x55, 0x4e}, []uint8{0x59, 0x55, 0x52}, []uint8{0x5a, 0x41, 0x4c}, []uint8{0x5a, 0x41, 0x52}, []uint8{0x5a, 0x4d, 0x4b}, []uint8{0x5a, 0x4d, 0x57}, []uint8{0x5a, 0x52, 0x4e}, []uint8{0x5a, 0x52, 0x5a}, []uint8{0x5a, 0x57, 0x44}, []uint8{0x5a, 0x57, 0x4c}, []uint8{0x5a, 0x57, 0x52}},
}
}
@@ -136,19 +136,15 @@ func (ar *ar) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (ar *ar) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ar.decimal) + len(ar.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(ar.decimal) - 1; j >= 0; j-- {
b = append(b, ar.decimal[j])
}
@@ -159,9 +155,7 @@ func (ar *ar) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(ar.group) - 1; j >= 0; j-- {
b = append(b, ar.group[j])
}
@@ -175,11 +169,16 @@ func (ar *ar) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(ar.minus) - 1; j >= 0; j-- {
+ b = append(b, ar.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ar_001/ar_001.go b/ar_001/ar_001.go
index 714c827d..5eacd574 100644
--- a/ar_001/ar_001.go
+++ b/ar_001/ar_001.go
@@ -136,19 +136,15 @@ func (ar *ar_001) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint
// avoid allocations; otherwise just cast as string.
func (ar *ar_001) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ar.decimal) + len(ar.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(ar.decimal) - 1; j >= 0; j-- {
b = append(b, ar.decimal[j])
}
@@ -159,9 +155,7 @@ func (ar *ar_001) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(ar.group) - 1; j >= 0; j-- {
b = append(b, ar.group[j])
}
@@ -175,11 +169,16 @@ func (ar *ar_001) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(ar.minus) - 1; j >= 0; j-- {
+ b = append(b, ar.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ar_AE/ar_AE.go b/ar_AE/ar_AE.go
index 2eebcdac..ae26995d 100644
--- a/ar_AE/ar_AE.go
+++ b/ar_AE/ar_AE.go
@@ -136,19 +136,15 @@ func (ar *ar_AE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ar *ar_AE) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ar.decimal) + len(ar.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(ar.decimal) - 1; j >= 0; j-- {
b = append(b, ar.decimal[j])
}
@@ -159,9 +155,7 @@ func (ar *ar_AE) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(ar.group) - 1; j >= 0; j-- {
b = append(b, ar.group[j])
}
@@ -175,11 +169,16 @@ func (ar *ar_AE) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(ar.minus) - 1; j >= 0; j-- {
+ b = append(b, ar.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ar_BH/ar_BH.go b/ar_BH/ar_BH.go
index 8cb62f9d..851d0c99 100644
--- a/ar_BH/ar_BH.go
+++ b/ar_BH/ar_BH.go
@@ -136,19 +136,15 @@ func (ar *ar_BH) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ar *ar_BH) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ar.decimal) + len(ar.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(ar.decimal) - 1; j >= 0; j-- {
b = append(b, ar.decimal[j])
}
@@ -159,9 +155,7 @@ func (ar *ar_BH) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(ar.group) - 1; j >= 0; j-- {
b = append(b, ar.group[j])
}
@@ -175,11 +169,16 @@ func (ar *ar_BH) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(ar.minus) - 1; j >= 0; j-- {
+ b = append(b, ar.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ar_DJ/ar_DJ.go b/ar_DJ/ar_DJ.go
index c0ccbbe5..9b362228 100644
--- a/ar_DJ/ar_DJ.go
+++ b/ar_DJ/ar_DJ.go
@@ -136,19 +136,15 @@ func (ar *ar_DJ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ar *ar_DJ) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ar.decimal) + len(ar.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(ar.decimal) - 1; j >= 0; j-- {
b = append(b, ar.decimal[j])
}
@@ -159,9 +155,7 @@ func (ar *ar_DJ) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(ar.group) - 1; j >= 0; j-- {
b = append(b, ar.group[j])
}
@@ -175,11 +169,16 @@ func (ar *ar_DJ) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(ar.minus) - 1; j >= 0; j-- {
+ b = append(b, ar.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ar_DZ/ar_DZ.go b/ar_DZ/ar_DZ.go
index eee25d9c..c1701208 100644
--- a/ar_DZ/ar_DZ.go
+++ b/ar_DZ/ar_DZ.go
@@ -136,36 +136,24 @@ func (ar *ar_DZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ar *ar_DZ) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ar.decimal) + len(ar.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ar.decimal) - 1; j >= 0; j-- {
- b = append(b, ar.decimal[j])
- }
-
+ b = append(b, ar.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(ar.group) - 1; j >= 0; j-- {
- b = append(b, ar.group[j])
- }
-
+ b = append(b, ar.group[0])
count = 1
} else {
count++
@@ -175,11 +163,16 @@ func (ar *ar_DZ) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(ar.minus) - 1; j >= 0; j-- {
+ b = append(b, ar.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ar_EG/ar_EG.go b/ar_EG/ar_EG.go
index 2d26e25c..bd4992f7 100644
--- a/ar_EG/ar_EG.go
+++ b/ar_EG/ar_EG.go
@@ -136,19 +136,15 @@ func (ar *ar_EG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ar *ar_EG) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ar.decimal) + len(ar.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(ar.decimal) - 1; j >= 0; j-- {
b = append(b, ar.decimal[j])
}
@@ -159,9 +155,7 @@ func (ar *ar_EG) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(ar.group) - 1; j >= 0; j-- {
b = append(b, ar.group[j])
}
@@ -175,11 +169,16 @@ func (ar *ar_EG) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(ar.minus) - 1; j >= 0; j-- {
+ b = append(b, ar.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ar_EH/ar_EH.go b/ar_EH/ar_EH.go
index 33d3ef4f..0c3d85ef 100644
--- a/ar_EH/ar_EH.go
+++ b/ar_EH/ar_EH.go
@@ -136,19 +136,15 @@ func (ar *ar_EH) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ar *ar_EH) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ar.decimal) + len(ar.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(ar.decimal) - 1; j >= 0; j-- {
b = append(b, ar.decimal[j])
}
@@ -159,9 +155,7 @@ func (ar *ar_EH) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(ar.group) - 1; j >= 0; j-- {
b = append(b, ar.group[j])
}
@@ -175,11 +169,16 @@ func (ar *ar_EH) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(ar.minus) - 1; j >= 0; j-- {
+ b = append(b, ar.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ar_ER/ar_ER.go b/ar_ER/ar_ER.go
index ec27f6b6..4ff335a7 100644
--- a/ar_ER/ar_ER.go
+++ b/ar_ER/ar_ER.go
@@ -136,19 +136,15 @@ func (ar *ar_ER) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ar *ar_ER) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ar.decimal) + len(ar.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(ar.decimal) - 1; j >= 0; j-- {
b = append(b, ar.decimal[j])
}
@@ -159,9 +155,7 @@ func (ar *ar_ER) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(ar.group) - 1; j >= 0; j-- {
b = append(b, ar.group[j])
}
@@ -175,11 +169,16 @@ func (ar *ar_ER) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(ar.minus) - 1; j >= 0; j-- {
+ b = append(b, ar.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ar_IL/ar_IL.go b/ar_IL/ar_IL.go
index 0252a8ae..3e1d6ead 100644
--- a/ar_IL/ar_IL.go
+++ b/ar_IL/ar_IL.go
@@ -136,19 +136,15 @@ func (ar *ar_IL) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ar *ar_IL) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ar.decimal) + len(ar.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(ar.decimal) - 1; j >= 0; j-- {
b = append(b, ar.decimal[j])
}
@@ -159,9 +155,7 @@ func (ar *ar_IL) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(ar.group) - 1; j >= 0; j-- {
b = append(b, ar.group[j])
}
@@ -175,11 +169,16 @@ func (ar *ar_IL) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(ar.minus) - 1; j >= 0; j-- {
+ b = append(b, ar.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ar_IQ/ar_IQ.go b/ar_IQ/ar_IQ.go
index 47d8f366..e45c0b0e 100644
--- a/ar_IQ/ar_IQ.go
+++ b/ar_IQ/ar_IQ.go
@@ -136,19 +136,15 @@ func (ar *ar_IQ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ar *ar_IQ) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ar.decimal) + len(ar.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(ar.decimal) - 1; j >= 0; j-- {
b = append(b, ar.decimal[j])
}
@@ -159,9 +155,7 @@ func (ar *ar_IQ) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(ar.group) - 1; j >= 0; j-- {
b = append(b, ar.group[j])
}
@@ -175,11 +169,16 @@ func (ar *ar_IQ) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(ar.minus) - 1; j >= 0; j-- {
+ b = append(b, ar.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ar_JO/ar_JO.go b/ar_JO/ar_JO.go
index a73b1511..419d17c7 100644
--- a/ar_JO/ar_JO.go
+++ b/ar_JO/ar_JO.go
@@ -136,19 +136,15 @@ func (ar *ar_JO) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ar *ar_JO) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ar.decimal) + len(ar.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(ar.decimal) - 1; j >= 0; j-- {
b = append(b, ar.decimal[j])
}
@@ -159,9 +155,7 @@ func (ar *ar_JO) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(ar.group) - 1; j >= 0; j-- {
b = append(b, ar.group[j])
}
@@ -175,11 +169,16 @@ func (ar *ar_JO) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(ar.minus) - 1; j >= 0; j-- {
+ b = append(b, ar.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ar_KM/ar_KM.go b/ar_KM/ar_KM.go
index 6ac7a651..dba08eba 100644
--- a/ar_KM/ar_KM.go
+++ b/ar_KM/ar_KM.go
@@ -136,19 +136,15 @@ func (ar *ar_KM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ar *ar_KM) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ar.decimal) + len(ar.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(ar.decimal) - 1; j >= 0; j-- {
b = append(b, ar.decimal[j])
}
@@ -159,9 +155,7 @@ func (ar *ar_KM) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(ar.group) - 1; j >= 0; j-- {
b = append(b, ar.group[j])
}
@@ -175,11 +169,16 @@ func (ar *ar_KM) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(ar.minus) - 1; j >= 0; j-- {
+ b = append(b, ar.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ar_KW/ar_KW.go b/ar_KW/ar_KW.go
index 101968bc..bbb2df78 100644
--- a/ar_KW/ar_KW.go
+++ b/ar_KW/ar_KW.go
@@ -136,19 +136,15 @@ func (ar *ar_KW) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ar *ar_KW) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ar.decimal) + len(ar.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(ar.decimal) - 1; j >= 0; j-- {
b = append(b, ar.decimal[j])
}
@@ -159,9 +155,7 @@ func (ar *ar_KW) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(ar.group) - 1; j >= 0; j-- {
b = append(b, ar.group[j])
}
@@ -175,11 +169,16 @@ func (ar *ar_KW) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(ar.minus) - 1; j >= 0; j-- {
+ b = append(b, ar.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ar_LB/ar_LB.go b/ar_LB/ar_LB.go
index b7f31946..81cc8ccc 100644
--- a/ar_LB/ar_LB.go
+++ b/ar_LB/ar_LB.go
@@ -136,36 +136,24 @@ func (ar *ar_LB) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ar *ar_LB) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ar.decimal) + len(ar.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ar.decimal) - 1; j >= 0; j-- {
- b = append(b, ar.decimal[j])
- }
-
+ b = append(b, ar.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(ar.group) - 1; j >= 0; j-- {
- b = append(b, ar.group[j])
- }
-
+ b = append(b, ar.group[0])
count = 1
} else {
count++
@@ -175,11 +163,16 @@ func (ar *ar_LB) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(ar.minus) - 1; j >= 0; j-- {
+ b = append(b, ar.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ar_LY/ar_LY.go b/ar_LY/ar_LY.go
index 0dd86bd8..1a4f7653 100644
--- a/ar_LY/ar_LY.go
+++ b/ar_LY/ar_LY.go
@@ -136,36 +136,24 @@ func (ar *ar_LY) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ar *ar_LY) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ar.decimal) + len(ar.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ar.decimal) - 1; j >= 0; j-- {
- b = append(b, ar.decimal[j])
- }
-
+ b = append(b, ar.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(ar.group) - 1; j >= 0; j-- {
- b = append(b, ar.group[j])
- }
-
+ b = append(b, ar.group[0])
count = 1
} else {
count++
@@ -175,11 +163,16 @@ func (ar *ar_LY) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(ar.minus) - 1; j >= 0; j-- {
+ b = append(b, ar.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ar_MA/ar_MA.go b/ar_MA/ar_MA.go
index ab8cc09e..43b53c47 100644
--- a/ar_MA/ar_MA.go
+++ b/ar_MA/ar_MA.go
@@ -136,36 +136,24 @@ func (ar *ar_MA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ar *ar_MA) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ar.decimal) + len(ar.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ar.decimal) - 1; j >= 0; j-- {
- b = append(b, ar.decimal[j])
- }
-
+ b = append(b, ar.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(ar.group) - 1; j >= 0; j-- {
- b = append(b, ar.group[j])
- }
-
+ b = append(b, ar.group[0])
count = 1
} else {
count++
@@ -175,11 +163,16 @@ func (ar *ar_MA) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(ar.minus) - 1; j >= 0; j-- {
+ b = append(b, ar.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ar_MR/ar_MR.go b/ar_MR/ar_MR.go
index 1d4d1e63..bfb6274f 100644
--- a/ar_MR/ar_MR.go
+++ b/ar_MR/ar_MR.go
@@ -136,36 +136,24 @@ func (ar *ar_MR) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ar *ar_MR) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ar.decimal) + len(ar.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ar.decimal) - 1; j >= 0; j-- {
- b = append(b, ar.decimal[j])
- }
-
+ b = append(b, ar.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(ar.group) - 1; j >= 0; j-- {
- b = append(b, ar.group[j])
- }
-
+ b = append(b, ar.group[0])
count = 1
} else {
count++
@@ -175,11 +163,16 @@ func (ar *ar_MR) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(ar.minus) - 1; j >= 0; j-- {
+ b = append(b, ar.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ar_OM/ar_OM.go b/ar_OM/ar_OM.go
index db913321..8446d8d4 100644
--- a/ar_OM/ar_OM.go
+++ b/ar_OM/ar_OM.go
@@ -136,19 +136,15 @@ func (ar *ar_OM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ar *ar_OM) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ar.decimal) + len(ar.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(ar.decimal) - 1; j >= 0; j-- {
b = append(b, ar.decimal[j])
}
@@ -159,9 +155,7 @@ func (ar *ar_OM) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(ar.group) - 1; j >= 0; j-- {
b = append(b, ar.group[j])
}
@@ -175,11 +169,16 @@ func (ar *ar_OM) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(ar.minus) - 1; j >= 0; j-- {
+ b = append(b, ar.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ar_PS/ar_PS.go b/ar_PS/ar_PS.go
index be0f801c..97f5dc43 100644
--- a/ar_PS/ar_PS.go
+++ b/ar_PS/ar_PS.go
@@ -136,19 +136,15 @@ func (ar *ar_PS) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ar *ar_PS) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ar.decimal) + len(ar.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(ar.decimal) - 1; j >= 0; j-- {
b = append(b, ar.decimal[j])
}
@@ -159,9 +155,7 @@ func (ar *ar_PS) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(ar.group) - 1; j >= 0; j-- {
b = append(b, ar.group[j])
}
@@ -175,11 +169,16 @@ func (ar *ar_PS) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(ar.minus) - 1; j >= 0; j-- {
+ b = append(b, ar.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ar_QA/ar_QA.go b/ar_QA/ar_QA.go
index 0b05ca11..9e28c1cd 100644
--- a/ar_QA/ar_QA.go
+++ b/ar_QA/ar_QA.go
@@ -136,19 +136,15 @@ func (ar *ar_QA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ar *ar_QA) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ar.decimal) + len(ar.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(ar.decimal) - 1; j >= 0; j-- {
b = append(b, ar.decimal[j])
}
@@ -159,9 +155,7 @@ func (ar *ar_QA) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(ar.group) - 1; j >= 0; j-- {
b = append(b, ar.group[j])
}
@@ -175,11 +169,16 @@ func (ar *ar_QA) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(ar.minus) - 1; j >= 0; j-- {
+ b = append(b, ar.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ar_SA/ar_SA.go b/ar_SA/ar_SA.go
index bd262aca..83ef8a45 100644
--- a/ar_SA/ar_SA.go
+++ b/ar_SA/ar_SA.go
@@ -136,19 +136,15 @@ func (ar *ar_SA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ar *ar_SA) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ar.decimal) + len(ar.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(ar.decimal) - 1; j >= 0; j-- {
b = append(b, ar.decimal[j])
}
@@ -159,9 +155,7 @@ func (ar *ar_SA) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(ar.group) - 1; j >= 0; j-- {
b = append(b, ar.group[j])
}
@@ -175,11 +169,16 @@ func (ar *ar_SA) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(ar.minus) - 1; j >= 0; j-- {
+ b = append(b, ar.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ar_SD/ar_SD.go b/ar_SD/ar_SD.go
index 2b353d3b..e930acc3 100644
--- a/ar_SD/ar_SD.go
+++ b/ar_SD/ar_SD.go
@@ -136,19 +136,15 @@ func (ar *ar_SD) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ar *ar_SD) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ar.decimal) + len(ar.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(ar.decimal) - 1; j >= 0; j-- {
b = append(b, ar.decimal[j])
}
@@ -159,9 +155,7 @@ func (ar *ar_SD) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(ar.group) - 1; j >= 0; j-- {
b = append(b, ar.group[j])
}
@@ -175,11 +169,16 @@ func (ar *ar_SD) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(ar.minus) - 1; j >= 0; j-- {
+ b = append(b, ar.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ar_SO/ar_SO.go b/ar_SO/ar_SO.go
index 5e6f1bd1..2c9f838c 100644
--- a/ar_SO/ar_SO.go
+++ b/ar_SO/ar_SO.go
@@ -136,19 +136,15 @@ func (ar *ar_SO) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ar *ar_SO) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ar.decimal) + len(ar.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(ar.decimal) - 1; j >= 0; j-- {
b = append(b, ar.decimal[j])
}
@@ -159,9 +155,7 @@ func (ar *ar_SO) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(ar.group) - 1; j >= 0; j-- {
b = append(b, ar.group[j])
}
@@ -175,11 +169,16 @@ func (ar *ar_SO) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(ar.minus) - 1; j >= 0; j-- {
+ b = append(b, ar.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ar_SS/ar_SS.go b/ar_SS/ar_SS.go
index 002939b3..ee45152f 100644
--- a/ar_SS/ar_SS.go
+++ b/ar_SS/ar_SS.go
@@ -136,19 +136,15 @@ func (ar *ar_SS) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ar *ar_SS) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ar.decimal) + len(ar.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(ar.decimal) - 1; j >= 0; j-- {
b = append(b, ar.decimal[j])
}
@@ -159,9 +155,7 @@ func (ar *ar_SS) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(ar.group) - 1; j >= 0; j-- {
b = append(b, ar.group[j])
}
@@ -175,11 +169,16 @@ func (ar *ar_SS) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(ar.minus) - 1; j >= 0; j-- {
+ b = append(b, ar.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ar_SY/ar_SY.go b/ar_SY/ar_SY.go
index f1a63b5e..2b3f0844 100644
--- a/ar_SY/ar_SY.go
+++ b/ar_SY/ar_SY.go
@@ -136,19 +136,15 @@ func (ar *ar_SY) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ar *ar_SY) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ar.decimal) + len(ar.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(ar.decimal) - 1; j >= 0; j-- {
b = append(b, ar.decimal[j])
}
@@ -159,9 +155,7 @@ func (ar *ar_SY) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(ar.group) - 1; j >= 0; j-- {
b = append(b, ar.group[j])
}
@@ -175,11 +169,16 @@ func (ar *ar_SY) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(ar.minus) - 1; j >= 0; j-- {
+ b = append(b, ar.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ar_TD/ar_TD.go b/ar_TD/ar_TD.go
index c59feeff..659ce3b5 100644
--- a/ar_TD/ar_TD.go
+++ b/ar_TD/ar_TD.go
@@ -136,19 +136,15 @@ func (ar *ar_TD) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ar *ar_TD) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ar.decimal) + len(ar.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(ar.decimal) - 1; j >= 0; j-- {
b = append(b, ar.decimal[j])
}
@@ -159,9 +155,7 @@ func (ar *ar_TD) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(ar.group) - 1; j >= 0; j-- {
b = append(b, ar.group[j])
}
@@ -175,11 +169,16 @@ func (ar *ar_TD) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(ar.minus) - 1; j >= 0; j-- {
+ b = append(b, ar.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ar_TN/ar_TN.go b/ar_TN/ar_TN.go
index 8b487ca0..19323bb2 100644
--- a/ar_TN/ar_TN.go
+++ b/ar_TN/ar_TN.go
@@ -136,36 +136,24 @@ func (ar *ar_TN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ar *ar_TN) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ar.decimal) + len(ar.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ar.decimal) - 1; j >= 0; j-- {
- b = append(b, ar.decimal[j])
- }
-
+ b = append(b, ar.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(ar.group) - 1; j >= 0; j-- {
- b = append(b, ar.group[j])
- }
-
+ b = append(b, ar.group[0])
count = 1
} else {
count++
@@ -175,11 +163,16 @@ func (ar *ar_TN) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(ar.minus) - 1; j >= 0; j-- {
+ b = append(b, ar.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ar_YE/ar_YE.go b/ar_YE/ar_YE.go
index 52fa6fec..e70e2904 100644
--- a/ar_YE/ar_YE.go
+++ b/ar_YE/ar_YE.go
@@ -136,19 +136,15 @@ func (ar *ar_YE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ar *ar_YE) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ar.decimal) + len(ar.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(ar.decimal) - 1; j >= 0; j-- {
b = append(b, ar.decimal[j])
}
@@ -159,9 +155,7 @@ func (ar *ar_YE) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(ar.group) - 1; j >= 0; j-- {
b = append(b, ar.group[j])
}
@@ -175,11 +169,16 @@ func (ar *ar_YE) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(ar.minus) - 1; j >= 0; j-- {
+ b = append(b, ar.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/as/as.go b/as/as.go
index 340aed51..bbde15a6 100644
--- a/as/as.go
+++ b/as/as.go
@@ -90,19 +90,18 @@ func (as *as) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (as *as) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(as.decimal) + len(as.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
+ inSecondary := false
+ groupThreshold := 3
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(as.decimal) - 1; j >= 0; j-- {
b = append(b, as.decimal[j])
}
@@ -114,13 +113,17 @@ func (as *as) FmtNumber(num float64, v uint64) []byte {
if inWhole {
- if count == 3 {
-
+ if count == groupThreshold {
for j := len(as.group) - 1; j >= 0; j-- {
b = append(b, as.group[j])
}
count = 1
+
+ if !inSecondary {
+ inSecondary = true
+ groupThreshold = 2
+ }
} else {
count++
}
@@ -129,11 +132,16 @@ func (as *as) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(as.minus) - 1; j >= 0; j-- {
+ b = append(b, as.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/as_IN/as_IN.go b/as_IN/as_IN.go
index 50c02071..37160bc8 100644
--- a/as_IN/as_IN.go
+++ b/as_IN/as_IN.go
@@ -90,19 +90,18 @@ func (as *as_IN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (as *as_IN) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(as.decimal) + len(as.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
+ inSecondary := false
+ groupThreshold := 3
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(as.decimal) - 1; j >= 0; j-- {
b = append(b, as.decimal[j])
}
@@ -114,13 +113,17 @@ func (as *as_IN) FmtNumber(num float64, v uint64) []byte {
if inWhole {
- if count == 3 {
-
+ if count == groupThreshold {
for j := len(as.group) - 1; j >= 0; j-- {
b = append(b, as.group[j])
}
count = 1
+
+ if !inSecondary {
+ inSecondary = true
+ groupThreshold = 2
+ }
} else {
count++
}
@@ -129,11 +132,16 @@ func (as *as_IN) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(as.minus) - 1; j >= 0; j-- {
+ b = append(b, as.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/asa/asa.go b/asa/asa.go
index 670b2d78..d0ec6529 100644
--- a/asa/asa.go
+++ b/asa/asa.go
@@ -76,8 +76,6 @@ func (asa *asa) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (asa *asa) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/asa_TZ/asa_TZ.go b/asa_TZ/asa_TZ.go
index 1b3a31b3..70b51044 100644
--- a/asa_TZ/asa_TZ.go
+++ b/asa_TZ/asa_TZ.go
@@ -76,8 +76,6 @@ func (asa *asa_TZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (asa *asa_TZ) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/ast/ast.go b/ast/ast.go
index c1f2a1f2..380a18dd 100644
--- a/ast/ast.go
+++ b/ast/ast.go
@@ -77,19 +77,15 @@ func (ast *ast) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (ast *ast) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ast.decimal) + len(ast.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(ast.decimal) - 1; j >= 0; j-- {
b = append(b, ast.decimal[j])
}
@@ -100,9 +96,7 @@ func (ast *ast) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(ast.group) - 1; j >= 0; j-- {
b = append(b, ast.group[j])
}
@@ -116,11 +110,16 @@ func (ast *ast) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(ast.minus) - 1; j >= 0; j-- {
+ b = append(b, ast.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ast_ES/ast_ES.go b/ast_ES/ast_ES.go
index e3aad2f1..0bf9f582 100644
--- a/ast_ES/ast_ES.go
+++ b/ast_ES/ast_ES.go
@@ -77,19 +77,15 @@ func (ast *ast_ES) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (ast *ast_ES) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ast.decimal) + len(ast.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(ast.decimal) - 1; j >= 0; j-- {
b = append(b, ast.decimal[j])
}
@@ -100,9 +96,7 @@ func (ast *ast_ES) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(ast.group) - 1; j >= 0; j-- {
b = append(b, ast.group[j])
}
@@ -116,11 +110,16 @@ func (ast *ast_ES) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(ast.minus) - 1; j >= 0; j-- {
+ b = append(b, ast.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/az/az.go b/az/az.go
index ea6728d6..3b70ed04 100644
--- a/az/az.go
+++ b/az/az.go
@@ -102,36 +102,24 @@ func (az *az) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (az *az) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(az.decimal) + len(az.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(az.decimal) - 1; j >= 0; j-- {
- b = append(b, az.decimal[j])
- }
-
+ b = append(b, az.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(az.group) - 1; j >= 0; j-- {
- b = append(b, az.group[j])
- }
-
+ b = append(b, az.group[0])
count = 1
} else {
count++
@@ -141,11 +129,14 @@ func (az *az) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, az.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/az_Cyrl/az_Cyrl.go b/az_Cyrl/az_Cyrl.go
index 8e335318..ee136c0a 100644
--- a/az_Cyrl/az_Cyrl.go
+++ b/az_Cyrl/az_Cyrl.go
@@ -102,36 +102,24 @@ func (az *az_Cyrl) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (az *az_Cyrl) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(az.decimal) + len(az.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(az.decimal) - 1; j >= 0; j-- {
- b = append(b, az.decimal[j])
- }
-
+ b = append(b, az.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(az.group) - 1; j >= 0; j-- {
- b = append(b, az.group[j])
- }
-
+ b = append(b, az.group[0])
count = 1
} else {
count++
@@ -141,11 +129,14 @@ func (az *az_Cyrl) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, az.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/az_Cyrl_AZ/az_Cyrl_AZ.go b/az_Cyrl_AZ/az_Cyrl_AZ.go
index fa381b06..bf8833c1 100644
--- a/az_Cyrl_AZ/az_Cyrl_AZ.go
+++ b/az_Cyrl_AZ/az_Cyrl_AZ.go
@@ -66,9 +66,9 @@ func (az *az_Cyrl_AZ) OrdinalPluralRule(num float64, v uint64) locales.PluralRul
n := math.Abs(num)
i := int64(n)
+ iMod1000 := i % 1000
iMod10 := i % 10
iMod100 := i % 100
- iMod1000 := i % 1000
if (iMod10 == 1 || iMod10 == 2 || iMod10 == 5 || iMod10 == 7 || iMod10 == 8) || (iMod100 == 20 || iMod100 == 50 || iMod100 == 70 || iMod100 == 80) {
return locales.PluralRuleOne
@@ -102,36 +102,24 @@ func (az *az_Cyrl_AZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2
// avoid allocations; otherwise just cast as string.
func (az *az_Cyrl_AZ) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(az.decimal) + len(az.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(az.decimal) - 1; j >= 0; j-- {
- b = append(b, az.decimal[j])
- }
-
+ b = append(b, az.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(az.group) - 1; j >= 0; j-- {
- b = append(b, az.group[j])
- }
-
+ b = append(b, az.group[0])
count = 1
} else {
count++
@@ -141,11 +129,14 @@ func (az *az_Cyrl_AZ) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, az.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/az_Latn/az_Latn.go b/az_Latn/az_Latn.go
index 39058bb1..933d4e3b 100644
--- a/az_Latn/az_Latn.go
+++ b/az_Latn/az_Latn.go
@@ -66,9 +66,9 @@ func (az *az_Latn) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
n := math.Abs(num)
i := int64(n)
- iMod1000 := i % 1000
iMod10 := i % 10
iMod100 := i % 100
+ iMod1000 := i % 1000
if (iMod10 == 1 || iMod10 == 2 || iMod10 == 5 || iMod10 == 7 || iMod10 == 8) || (iMod100 == 20 || iMod100 == 50 || iMod100 == 70 || iMod100 == 80) {
return locales.PluralRuleOne
@@ -102,36 +102,24 @@ func (az *az_Latn) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (az *az_Latn) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(az.decimal) + len(az.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(az.decimal) - 1; j >= 0; j-- {
- b = append(b, az.decimal[j])
- }
-
+ b = append(b, az.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(az.group) - 1; j >= 0; j-- {
- b = append(b, az.group[j])
- }
-
+ b = append(b, az.group[0])
count = 1
} else {
count++
@@ -141,11 +129,14 @@ func (az *az_Latn) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, az.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/az_Latn_AZ/az_Latn_AZ.go b/az_Latn_AZ/az_Latn_AZ.go
index 5e6fdd1a..975e8eb5 100644
--- a/az_Latn_AZ/az_Latn_AZ.go
+++ b/az_Latn_AZ/az_Latn_AZ.go
@@ -66,9 +66,9 @@ func (az *az_Latn_AZ) OrdinalPluralRule(num float64, v uint64) locales.PluralRul
n := math.Abs(num)
i := int64(n)
- iMod1000 := i % 1000
iMod10 := i % 10
iMod100 := i % 100
+ iMod1000 := i % 1000
if (iMod10 == 1 || iMod10 == 2 || iMod10 == 5 || iMod10 == 7 || iMod10 == 8) || (iMod100 == 20 || iMod100 == 50 || iMod100 == 70 || iMod100 == 80) {
return locales.PluralRuleOne
@@ -102,36 +102,24 @@ func (az *az_Latn_AZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2
// avoid allocations; otherwise just cast as string.
func (az *az_Latn_AZ) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(az.decimal) + len(az.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(az.decimal) - 1; j >= 0; j-- {
- b = append(b, az.decimal[j])
- }
-
+ b = append(b, az.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(az.group) - 1; j >= 0; j-- {
- b = append(b, az.group[j])
- }
-
+ b = append(b, az.group[0])
count = 1
} else {
count++
@@ -141,11 +129,14 @@ func (az *az_Latn_AZ) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, az.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/bas/bas.go b/bas/bas.go
index de68e9d8..ed64c1f0 100644
--- a/bas/bas.go
+++ b/bas/bas.go
@@ -1,6 +1,7 @@
package bas
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,32 +69,23 @@ func (bas *bas) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (bas *bas) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(bas.decimal) + len(bas.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(bas.decimal) - 1; j >= 0; j-- {
- b = append(b, bas.decimal[j])
- }
-
+ b = append(b, bas.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(bas.group) - 1; j >= 0; j-- {
b = append(b, bas.group[j])
}
@@ -107,11 +99,16 @@ func (bas *bas) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(bas.minus) - 1; j >= 0; j-- {
+ b = append(b, bas.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/bas_CM/bas_CM.go b/bas_CM/bas_CM.go
index 8eb06e23..5ae562ff 100644
--- a/bas_CM/bas_CM.go
+++ b/bas_CM/bas_CM.go
@@ -1,6 +1,7 @@
package bas_CM
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,32 +69,23 @@ func (bas *bas_CM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (bas *bas_CM) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(bas.decimal) + len(bas.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(bas.decimal) - 1; j >= 0; j-- {
- b = append(b, bas.decimal[j])
- }
-
+ b = append(b, bas.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(bas.group) - 1; j >= 0; j-- {
b = append(b, bas.group[j])
}
@@ -107,11 +99,16 @@ func (bas *bas_CM) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(bas.minus) - 1; j >= 0; j-- {
+ b = append(b, bas.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/be/be.go b/be/be.go
index f1ef57df..629f0d3a 100644
--- a/be/be.go
+++ b/be/be.go
@@ -91,32 +91,23 @@ func (be *be) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (be *be) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(be.decimal) + len(be.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(be.decimal) - 1; j >= 0; j-- {
- b = append(b, be.decimal[j])
- }
-
+ b = append(b, be.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(be.group) - 1; j >= 0; j-- {
b = append(b, be.group[j])
}
@@ -130,11 +121,14 @@ func (be *be) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, be.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/be_BY/be_BY.go b/be_BY/be_BY.go
index 52289483..9bb09acb 100644
--- a/be_BY/be_BY.go
+++ b/be_BY/be_BY.go
@@ -91,32 +91,23 @@ func (be *be_BY) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (be *be_BY) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(be.decimal) + len(be.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(be.decimal) - 1; j >= 0; j-- {
- b = append(b, be.decimal[j])
- }
-
+ b = append(b, be.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(be.group) - 1; j >= 0; j-- {
b = append(b, be.group[j])
}
@@ -130,11 +121,14 @@ func (be *be_BY) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, be.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/bem/bem.go b/bem/bem.go
index 6d0e3d76..757c65c1 100644
--- a/bem/bem.go
+++ b/bem/bem.go
@@ -76,8 +76,6 @@ func (bem *bem) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (bem *bem) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/bem_ZM/bem_ZM.go b/bem_ZM/bem_ZM.go
index bb443348..d7a8d0dd 100644
--- a/bem_ZM/bem_ZM.go
+++ b/bem_ZM/bem_ZM.go
@@ -76,8 +76,6 @@ func (bem *bem_ZM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (bem *bem_ZM) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/bez/bez.go b/bez/bez.go
index a3115ca5..0b2a2b0c 100644
--- a/bez/bez.go
+++ b/bez/bez.go
@@ -76,8 +76,6 @@ func (bez *bez) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (bez *bez) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/bez_TZ/bez_TZ.go b/bez_TZ/bez_TZ.go
index 610d4968..b6b38f36 100644
--- a/bez_TZ/bez_TZ.go
+++ b/bez_TZ/bez_TZ.go
@@ -76,8 +76,6 @@ func (bez *bez_TZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (bez *bez_TZ) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/bg/bg.go b/bg/bg.go
index 79efe83b..ae5e8504 100644
--- a/bg/bg.go
+++ b/bg/bg.go
@@ -76,32 +76,23 @@ func (bg *bg) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (bg *bg) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(bg.decimal) + len(bg.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(bg.decimal) - 1; j >= 0; j-- {
- b = append(b, bg.decimal[j])
- }
-
+ b = append(b, bg.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(bg.group) - 1; j >= 0; j-- {
b = append(b, bg.group[j])
}
@@ -115,11 +106,14 @@ func (bg *bg) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, bg.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/bg_BG/bg_BG.go b/bg_BG/bg_BG.go
index 4543a558..17a2dc5f 100644
--- a/bg_BG/bg_BG.go
+++ b/bg_BG/bg_BG.go
@@ -76,32 +76,23 @@ func (bg *bg_BG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (bg *bg_BG) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(bg.decimal) + len(bg.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(bg.decimal) - 1; j >= 0; j-- {
- b = append(b, bg.decimal[j])
- }
-
+ b = append(b, bg.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(bg.group) - 1; j >= 0; j-- {
b = append(b, bg.group[j])
}
@@ -115,11 +106,14 @@ func (bg *bg_BG) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, bg.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/bm/bm.go b/bm/bm.go
index 0d344f4e..6346e371 100644
--- a/bm/bm.go
+++ b/bm/bm.go
@@ -1,6 +1,7 @@
package bm
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,8 +69,6 @@ func (bm *bm) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (bm *bm) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/bm_ML/bm_ML.go b/bm_ML/bm_ML.go
index 2e574027..62206ecd 100644
--- a/bm_ML/bm_ML.go
+++ b/bm_ML/bm_ML.go
@@ -1,6 +1,7 @@
package bm_ML
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,8 +69,6 @@ func (bm *bm_ML) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (bm *bm_ML) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/bn/bn.go b/bn/bn.go
index 0b42bdb4..2c0ce957 100644
--- a/bn/bn.go
+++ b/bn/bn.go
@@ -101,19 +101,18 @@ func (bn *bn) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (bn *bn) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(bn.decimal) + len(bn.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
+ inSecondary := false
+ groupThreshold := 3
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(bn.decimal) - 1; j >= 0; j-- {
b = append(b, bn.decimal[j])
}
@@ -125,13 +124,17 @@ func (bn *bn) FmtNumber(num float64, v uint64) []byte {
if inWhole {
- if count == 3 {
-
+ if count == groupThreshold {
for j := len(bn.group) - 1; j >= 0; j-- {
b = append(b, bn.group[j])
}
count = 1
+
+ if !inSecondary {
+ inSecondary = true
+ groupThreshold = 2
+ }
} else {
count++
}
@@ -140,11 +143,16 @@ func (bn *bn) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(bn.minus) - 1; j >= 0; j-- {
+ b = append(b, bn.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/bn_BD/bn_BD.go b/bn_BD/bn_BD.go
index f3fc758d..9bb3b077 100644
--- a/bn_BD/bn_BD.go
+++ b/bn_BD/bn_BD.go
@@ -101,19 +101,18 @@ func (bn *bn_BD) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (bn *bn_BD) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(bn.decimal) + len(bn.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
+ inSecondary := false
+ groupThreshold := 3
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(bn.decimal) - 1; j >= 0; j-- {
b = append(b, bn.decimal[j])
}
@@ -125,13 +124,17 @@ func (bn *bn_BD) FmtNumber(num float64, v uint64) []byte {
if inWhole {
- if count == 3 {
-
+ if count == groupThreshold {
for j := len(bn.group) - 1; j >= 0; j-- {
b = append(b, bn.group[j])
}
count = 1
+
+ if !inSecondary {
+ inSecondary = true
+ groupThreshold = 2
+ }
} else {
count++
}
@@ -140,11 +143,16 @@ func (bn *bn_BD) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(bn.minus) - 1; j >= 0; j-- {
+ b = append(b, bn.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/bn_IN/bn_IN.go b/bn_IN/bn_IN.go
index e3bf1f09..2bff3043 100644
--- a/bn_IN/bn_IN.go
+++ b/bn_IN/bn_IN.go
@@ -101,19 +101,18 @@ func (bn *bn_IN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (bn *bn_IN) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(bn.decimal) + len(bn.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
+ inSecondary := false
+ groupThreshold := 3
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(bn.decimal) - 1; j >= 0; j-- {
b = append(b, bn.decimal[j])
}
@@ -125,13 +124,17 @@ func (bn *bn_IN) FmtNumber(num float64, v uint64) []byte {
if inWhole {
- if count == 3 {
-
+ if count == groupThreshold {
for j := len(bn.group) - 1; j >= 0; j-- {
b = append(b, bn.group[j])
}
count = 1
+
+ if !inSecondary {
+ inSecondary = true
+ groupThreshold = 2
+ }
} else {
count++
}
@@ -140,11 +143,16 @@ func (bn *bn_IN) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(bn.minus) - 1; j >= 0; j-- {
+ b = append(b, bn.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/bo/bo.go b/bo/bo.go
index 72e35fa0..cb535017 100644
--- a/bo/bo.go
+++ b/bo/bo.go
@@ -1,6 +1,7 @@
package bo
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,36 +69,24 @@ func (bo *bo) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (bo *bo) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(bo.decimal) + len(bo.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(bo.decimal) - 1; j >= 0; j-- {
- b = append(b, bo.decimal[j])
- }
-
+ b = append(b, bo.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(bo.group) - 1; j >= 0; j-- {
- b = append(b, bo.group[j])
- }
-
+ b = append(b, bo.group[0])
count = 1
} else {
count++
@@ -107,11 +96,16 @@ func (bo *bo) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(bo.minus) - 1; j >= 0; j-- {
+ b = append(b, bo.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/bo_CN/bo_CN.go b/bo_CN/bo_CN.go
index 7db90878..2d46d23a 100644
--- a/bo_CN/bo_CN.go
+++ b/bo_CN/bo_CN.go
@@ -1,6 +1,7 @@
package bo_CN
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,36 +69,24 @@ func (bo *bo_CN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (bo *bo_CN) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(bo.decimal) + len(bo.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(bo.decimal) - 1; j >= 0; j-- {
- b = append(b, bo.decimal[j])
- }
-
+ b = append(b, bo.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(bo.group) - 1; j >= 0; j-- {
- b = append(b, bo.group[j])
- }
-
+ b = append(b, bo.group[0])
count = 1
} else {
count++
@@ -107,11 +96,16 @@ func (bo *bo_CN) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(bo.minus) - 1; j >= 0; j-- {
+ b = append(b, bo.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/bo_IN/bo_IN.go b/bo_IN/bo_IN.go
index 2cd88fb0..a538938f 100644
--- a/bo_IN/bo_IN.go
+++ b/bo_IN/bo_IN.go
@@ -1,6 +1,7 @@
package bo_IN
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,36 +69,24 @@ func (bo *bo_IN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (bo *bo_IN) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(bo.decimal) + len(bo.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(bo.decimal) - 1; j >= 0; j-- {
- b = append(b, bo.decimal[j])
- }
-
+ b = append(b, bo.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(bo.group) - 1; j >= 0; j-- {
- b = append(b, bo.group[j])
- }
-
+ b = append(b, bo.group[0])
count = 1
} else {
count++
@@ -107,11 +96,16 @@ func (bo *bo_IN) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(bo.minus) - 1; j >= 0; j-- {
+ b = append(b, bo.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/br/br.go b/br/br.go
index 242107a3..61a87522 100644
--- a/br/br.go
+++ b/br/br.go
@@ -85,19 +85,15 @@ func (br *br) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (br *br) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(br.decimal) + len(br.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(br.decimal) - 1; j >= 0; j-- {
b = append(b, br.decimal[j])
}
@@ -108,9 +104,7 @@ func (br *br) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(br.group) - 1; j >= 0; j-- {
b = append(b, br.group[j])
}
@@ -124,11 +118,16 @@ func (br *br) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(br.minus) - 1; j >= 0; j-- {
+ b = append(b, br.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/br_FR/br_FR.go b/br_FR/br_FR.go
index 4e4bd8cd..a8a3fb47 100644
--- a/br_FR/br_FR.go
+++ b/br_FR/br_FR.go
@@ -85,19 +85,15 @@ func (br *br_FR) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (br *br_FR) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(br.decimal) + len(br.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(br.decimal) - 1; j >= 0; j-- {
b = append(b, br.decimal[j])
}
@@ -108,9 +104,7 @@ func (br *br_FR) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(br.group) - 1; j >= 0; j-- {
b = append(b, br.group[j])
}
@@ -124,11 +118,16 @@ func (br *br_FR) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(br.minus) - 1; j >= 0; j-- {
+ b = append(b, br.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/brx/brx.go b/brx/brx.go
index 230f168a..fe9d996c 100644
--- a/brx/brx.go
+++ b/brx/brx.go
@@ -76,23 +76,19 @@ func (brx *brx) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (brx *brx) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(brx.decimal) + len(brx.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
+ inSecondary := false
+ groupThreshold := 3
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(brx.decimal) - 1; j >= 0; j-- {
- b = append(b, brx.decimal[j])
- }
-
+ b = append(b, brx.decimal[0])
inWhole = true
continue
@@ -100,13 +96,14 @@ func (brx *brx) FmtNumber(num float64, v uint64) []byte {
if inWhole {
- if count == 3 {
+ if count == groupThreshold {
+ b = append(b, brx.group[0])
+ count = 1
- for j := len(brx.group) - 1; j >= 0; j-- {
- b = append(b, brx.group[j])
+ if !inSecondary {
+ inSecondary = true
+ groupThreshold = 2
}
-
- count = 1
} else {
count++
}
@@ -115,11 +112,14 @@ func (brx *brx) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, brx.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/brx_IN/brx_IN.go b/brx_IN/brx_IN.go
index 4df566ed..4211541f 100644
--- a/brx_IN/brx_IN.go
+++ b/brx_IN/brx_IN.go
@@ -76,23 +76,19 @@ func (brx *brx_IN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (brx *brx_IN) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(brx.decimal) + len(brx.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
+ inSecondary := false
+ groupThreshold := 3
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(brx.decimal) - 1; j >= 0; j-- {
- b = append(b, brx.decimal[j])
- }
-
+ b = append(b, brx.decimal[0])
inWhole = true
continue
@@ -100,13 +96,14 @@ func (brx *brx_IN) FmtNumber(num float64, v uint64) []byte {
if inWhole {
- if count == 3 {
+ if count == groupThreshold {
+ b = append(b, brx.group[0])
+ count = 1
- for j := len(brx.group) - 1; j >= 0; j-- {
- b = append(b, brx.group[j])
+ if !inSecondary {
+ inSecondary = true
+ groupThreshold = 2
}
-
- count = 1
} else {
count++
}
@@ -115,11 +112,14 @@ func (brx *brx_IN) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, brx.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/bs/bs.go b/bs/bs.go
index 0fed66a0..e833b468 100644
--- a/bs/bs.go
+++ b/bs/bs.go
@@ -107,36 +107,24 @@ func (bs *bs) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (bs *bs) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(bs.decimal) + len(bs.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(bs.decimal) - 1; j >= 0; j-- {
- b = append(b, bs.decimal[j])
- }
-
+ b = append(b, bs.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(bs.group) - 1; j >= 0; j-- {
- b = append(b, bs.group[j])
- }
-
+ b = append(b, bs.group[0])
count = 1
} else {
count++
@@ -146,11 +134,14 @@ func (bs *bs) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, bs.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/bs_Cyrl/bs_Cyrl.go b/bs_Cyrl/bs_Cyrl.go
index cb76a085..7169423a 100644
--- a/bs_Cyrl/bs_Cyrl.go
+++ b/bs_Cyrl/bs_Cyrl.go
@@ -57,8 +57,8 @@ func (bs *bs_Cyrl) CardinalPluralRule(num float64, v uint64) locales.PluralRule
f := locales.F(n, v)
iMod10 := i % 10
iMod100 := i % 100
- fMod10 := f % 10
fMod100 := f % 100
+ fMod10 := f % 10
if (v == 0 && iMod10 == 1 && iMod100 != 11) || (fMod10 == 1 && fMod100 != 11) {
return locales.PluralRuleOne
@@ -107,36 +107,24 @@ func (bs *bs_Cyrl) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (bs *bs_Cyrl) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(bs.decimal) + len(bs.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(bs.decimal) - 1; j >= 0; j-- {
- b = append(b, bs.decimal[j])
- }
-
+ b = append(b, bs.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(bs.group) - 1; j >= 0; j-- {
- b = append(b, bs.group[j])
- }
-
+ b = append(b, bs.group[0])
count = 1
} else {
count++
@@ -146,11 +134,14 @@ func (bs *bs_Cyrl) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, bs.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/bs_Cyrl_BA/bs_Cyrl_BA.go b/bs_Cyrl_BA/bs_Cyrl_BA.go
index c6c97795..1faef28a 100644
--- a/bs_Cyrl_BA/bs_Cyrl_BA.go
+++ b/bs_Cyrl_BA/bs_Cyrl_BA.go
@@ -107,36 +107,24 @@ func (bs *bs_Cyrl_BA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2
// avoid allocations; otherwise just cast as string.
func (bs *bs_Cyrl_BA) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(bs.decimal) + len(bs.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(bs.decimal) - 1; j >= 0; j-- {
- b = append(b, bs.decimal[j])
- }
-
+ b = append(b, bs.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(bs.group) - 1; j >= 0; j-- {
- b = append(b, bs.group[j])
- }
-
+ b = append(b, bs.group[0])
count = 1
} else {
count++
@@ -146,11 +134,14 @@ func (bs *bs_Cyrl_BA) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, bs.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/bs_Latn/bs_Latn.go b/bs_Latn/bs_Latn.go
index d2546d01..cde70ada 100644
--- a/bs_Latn/bs_Latn.go
+++ b/bs_Latn/bs_Latn.go
@@ -55,8 +55,8 @@ func (bs *bs_Latn) CardinalPluralRule(num float64, v uint64) locales.PluralRule
n := math.Abs(num)
i := int64(n)
f := locales.F(n, v)
- iMod100 := i % 100
iMod10 := i % 10
+ iMod100 := i % 100
fMod10 := f % 10
fMod100 := f % 100
@@ -107,36 +107,24 @@ func (bs *bs_Latn) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (bs *bs_Latn) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(bs.decimal) + len(bs.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(bs.decimal) - 1; j >= 0; j-- {
- b = append(b, bs.decimal[j])
- }
-
+ b = append(b, bs.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(bs.group) - 1; j >= 0; j-- {
- b = append(b, bs.group[j])
- }
-
+ b = append(b, bs.group[0])
count = 1
} else {
count++
@@ -146,11 +134,14 @@ func (bs *bs_Latn) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, bs.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/bs_Latn_BA/bs_Latn_BA.go b/bs_Latn_BA/bs_Latn_BA.go
index cbf63748..e9456fec 100644
--- a/bs_Latn_BA/bs_Latn_BA.go
+++ b/bs_Latn_BA/bs_Latn_BA.go
@@ -57,8 +57,8 @@ func (bs *bs_Latn_BA) CardinalPluralRule(num float64, v uint64) locales.PluralRu
f := locales.F(n, v)
iMod100 := i % 100
iMod10 := i % 10
- fMod100 := f % 100
fMod10 := f % 10
+ fMod100 := f % 100
if (v == 0 && iMod10 == 1 && iMod100 != 11) || (fMod10 == 1 && fMod100 != 11) {
return locales.PluralRuleOne
@@ -107,36 +107,24 @@ func (bs *bs_Latn_BA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2
// avoid allocations; otherwise just cast as string.
func (bs *bs_Latn_BA) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(bs.decimal) + len(bs.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(bs.decimal) - 1; j >= 0; j-- {
- b = append(b, bs.decimal[j])
- }
-
+ b = append(b, bs.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(bs.group) - 1; j >= 0; j-- {
- b = append(b, bs.group[j])
- }
-
+ b = append(b, bs.group[0])
count = 1
} else {
count++
@@ -146,11 +134,14 @@ func (bs *bs_Latn_BA) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, bs.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ca/ca.go b/ca/ca.go
index 37c4c5aa..94347261 100644
--- a/ca/ca.go
+++ b/ca/ca.go
@@ -88,36 +88,24 @@ func (ca *ca) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (ca *ca) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ca.decimal) + len(ca.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ca.decimal) - 1; j >= 0; j-- {
- b = append(b, ca.decimal[j])
- }
-
+ b = append(b, ca.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(ca.group) - 1; j >= 0; j-- {
- b = append(b, ca.group[j])
- }
-
+ b = append(b, ca.group[0])
count = 1
} else {
count++
@@ -127,11 +115,14 @@ func (ca *ca) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, ca.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ca_AD/ca_AD.go b/ca_AD/ca_AD.go
index d6af6927..26614f75 100644
--- a/ca_AD/ca_AD.go
+++ b/ca_AD/ca_AD.go
@@ -88,36 +88,24 @@ func (ca *ca_AD) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ca *ca_AD) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ca.decimal) + len(ca.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ca.decimal) - 1; j >= 0; j-- {
- b = append(b, ca.decimal[j])
- }
-
+ b = append(b, ca.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(ca.group) - 1; j >= 0; j-- {
- b = append(b, ca.group[j])
- }
-
+ b = append(b, ca.group[0])
count = 1
} else {
count++
@@ -127,11 +115,14 @@ func (ca *ca_AD) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, ca.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ca_ES/ca_ES.go b/ca_ES/ca_ES.go
index 57594254..e745913e 100644
--- a/ca_ES/ca_ES.go
+++ b/ca_ES/ca_ES.go
@@ -88,36 +88,24 @@ func (ca *ca_ES) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ca *ca_ES) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ca.decimal) + len(ca.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ca.decimal) - 1; j >= 0; j-- {
- b = append(b, ca.decimal[j])
- }
-
+ b = append(b, ca.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(ca.group) - 1; j >= 0; j-- {
- b = append(b, ca.group[j])
- }
-
+ b = append(b, ca.group[0])
count = 1
} else {
count++
@@ -127,11 +115,14 @@ func (ca *ca_ES) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, ca.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ca_ES_VALENCIA/ca_ES_VALENCIA.go b/ca_ES_VALENCIA/ca_ES_VALENCIA.go
index 45a7dc9e..14cf5ad6 100644
--- a/ca_ES_VALENCIA/ca_ES_VALENCIA.go
+++ b/ca_ES_VALENCIA/ca_ES_VALENCIA.go
@@ -88,36 +88,24 @@ func (ca *ca_ES_VALENCIA) RangePluralRule(num1 float64, v1 uint64, num2 float64,
// avoid allocations; otherwise just cast as string.
func (ca *ca_ES_VALENCIA) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ca.decimal) + len(ca.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ca.decimal) - 1; j >= 0; j-- {
- b = append(b, ca.decimal[j])
- }
-
+ b = append(b, ca.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(ca.group) - 1; j >= 0; j-- {
- b = append(b, ca.group[j])
- }
-
+ b = append(b, ca.group[0])
count = 1
} else {
count++
@@ -127,11 +115,14 @@ func (ca *ca_ES_VALENCIA) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, ca.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ca_FR/ca_FR.go b/ca_FR/ca_FR.go
index 63187920..78f02950 100644
--- a/ca_FR/ca_FR.go
+++ b/ca_FR/ca_FR.go
@@ -88,36 +88,24 @@ func (ca *ca_FR) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ca *ca_FR) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ca.decimal) + len(ca.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ca.decimal) - 1; j >= 0; j-- {
- b = append(b, ca.decimal[j])
- }
-
+ b = append(b, ca.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(ca.group) - 1; j >= 0; j-- {
- b = append(b, ca.group[j])
- }
-
+ b = append(b, ca.group[0])
count = 1
} else {
count++
@@ -127,11 +115,14 @@ func (ca *ca_FR) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, ca.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ca_IT/ca_IT.go b/ca_IT/ca_IT.go
index 3c51cdf9..53e8ff22 100644
--- a/ca_IT/ca_IT.go
+++ b/ca_IT/ca_IT.go
@@ -88,36 +88,24 @@ func (ca *ca_IT) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ca *ca_IT) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ca.decimal) + len(ca.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ca.decimal) - 1; j >= 0; j-- {
- b = append(b, ca.decimal[j])
- }
-
+ b = append(b, ca.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(ca.group) - 1; j >= 0; j-- {
- b = append(b, ca.group[j])
- }
-
+ b = append(b, ca.group[0])
count = 1
} else {
count++
@@ -127,11 +115,14 @@ func (ca *ca_IT) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, ca.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ce/ce.go b/ce/ce.go
index c78f4d78..d9fc3013 100644
--- a/ce/ce.go
+++ b/ce/ce.go
@@ -76,36 +76,24 @@ func (ce *ce) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (ce *ce) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ce.decimal) + len(ce.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ce.decimal) - 1; j >= 0; j-- {
- b = append(b, ce.decimal[j])
- }
-
+ b = append(b, ce.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(ce.group) - 1; j >= 0; j-- {
- b = append(b, ce.group[j])
- }
-
+ b = append(b, ce.group[0])
count = 1
} else {
count++
@@ -115,11 +103,14 @@ func (ce *ce) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, ce.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ce_RU/ce_RU.go b/ce_RU/ce_RU.go
index ca017916..12425097 100644
--- a/ce_RU/ce_RU.go
+++ b/ce_RU/ce_RU.go
@@ -76,36 +76,24 @@ func (ce *ce_RU) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ce *ce_RU) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ce.decimal) + len(ce.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ce.decimal) - 1; j >= 0; j-- {
- b = append(b, ce.decimal[j])
- }
-
+ b = append(b, ce.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(ce.group) - 1; j >= 0; j-- {
- b = append(b, ce.group[j])
- }
-
+ b = append(b, ce.group[0])
count = 1
} else {
count++
@@ -115,11 +103,14 @@ func (ce *ce_RU) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, ce.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/cgg/cgg.go b/cgg/cgg.go
index 2bb87d36..19386bf5 100644
--- a/cgg/cgg.go
+++ b/cgg/cgg.go
@@ -76,8 +76,6 @@ func (cgg *cgg) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (cgg *cgg) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/cgg_UG/cgg_UG.go b/cgg_UG/cgg_UG.go
index ebd87d5c..f277f546 100644
--- a/cgg_UG/cgg_UG.go
+++ b/cgg_UG/cgg_UG.go
@@ -76,8 +76,6 @@ func (cgg *cgg_UG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (cgg *cgg_UG) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/chr/chr.go b/chr/chr.go
index 63ea8d87..f05ded42 100644
--- a/chr/chr.go
+++ b/chr/chr.go
@@ -76,36 +76,24 @@ func (chr *chr) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (chr *chr) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(chr.decimal) + len(chr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(chr.decimal) - 1; j >= 0; j-- {
- b = append(b, chr.decimal[j])
- }
-
+ b = append(b, chr.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(chr.group) - 1; j >= 0; j-- {
- b = append(b, chr.group[j])
- }
-
+ b = append(b, chr.group[0])
count = 1
} else {
count++
@@ -115,11 +103,14 @@ func (chr *chr) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, chr.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/chr_US/chr_US.go b/chr_US/chr_US.go
index 8514bd92..c51ba44c 100644
--- a/chr_US/chr_US.go
+++ b/chr_US/chr_US.go
@@ -76,36 +76,24 @@ func (chr *chr_US) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (chr *chr_US) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(chr.decimal) + len(chr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(chr.decimal) - 1; j >= 0; j-- {
- b = append(b, chr.decimal[j])
- }
-
+ b = append(b, chr.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(chr.group) - 1; j >= 0; j-- {
- b = append(b, chr.group[j])
- }
-
+ b = append(b, chr.group[0])
count = 1
} else {
count++
@@ -115,11 +103,14 @@ func (chr *chr_US) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, chr.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ckb/ckb.go b/ckb/ckb.go
index 55739e91..85fde7d5 100644
--- a/ckb/ckb.go
+++ b/ckb/ckb.go
@@ -76,8 +76,6 @@ func (ckb *ckb) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (ckb *ckb) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/ckb_IQ/ckb_IQ.go b/ckb_IQ/ckb_IQ.go
index 4eedcc58..946d9ef0 100644
--- a/ckb_IQ/ckb_IQ.go
+++ b/ckb_IQ/ckb_IQ.go
@@ -76,8 +76,6 @@ func (ckb *ckb_IQ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (ckb *ckb_IQ) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/ckb_IR/ckb_IR.go b/ckb_IR/ckb_IR.go
index 2d378f6a..e0d25194 100644
--- a/ckb_IR/ckb_IR.go
+++ b/ckb_IR/ckb_IR.go
@@ -76,8 +76,6 @@ func (ckb *ckb_IR) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (ckb *ckb_IR) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/cmd/generate_resources.go b/cmd/generate_resources.go
index 49a3d78b..52e6a577 100644
--- a/cmd/generate_resources.go
+++ b/cmd/generate_resources.go
@@ -31,20 +31,21 @@ var (
"t": "t := locales.T(n, v)\n",
}
- translators = make(map[string]*translator)
- baseTranslators = make(map[string]*translator)
- globalCurrenciesMap = make(map[string]struct{}) // ["USD"] = "$" currency code, just all currencies for mapping to enum
- globCurrencyIdxMap = make(map[string]int) // ["USD"] = 0
- globalCurrencies = make([]string, 0, 100) // array of currency codes index maps to enum
- tmpl *template.Template
- nModRegex = regexp.MustCompile("(n%[0-9]+)")
- iModRegex = regexp.MustCompile("(i%[0-9]+)")
- wModRegex = regexp.MustCompile("(w%[0-9]+)")
- fModRegex = regexp.MustCompile("(f%[0-9]+)")
- tModRegex = regexp.MustCompile("(t%[0-9]+)")
- groupLenRegex = regexp.MustCompile(",([0-9#]+)\\.")
- requiredNumRegex = regexp.MustCompile("([0-9]+)\\.")
- requiredDecimalRegex = regexp.MustCompile("\\.([0-9]+)")
+ translators = make(map[string]*translator)
+ baseTranslators = make(map[string]*translator)
+ globalCurrenciesMap = make(map[string]struct{}) // ["USD"] = "$" currency code, just all currencies for mapping to enum
+ globCurrencyIdxMap = make(map[string]int) // ["USD"] = 0
+ globalCurrencies = make([]string, 0, 100) // array of currency codes index maps to enum
+ tmpl *template.Template
+ nModRegex = regexp.MustCompile("(n%[0-9]+)")
+ iModRegex = regexp.MustCompile("(i%[0-9]+)")
+ wModRegex = regexp.MustCompile("(w%[0-9]+)")
+ fModRegex = regexp.MustCompile("(f%[0-9]+)")
+ tModRegex = regexp.MustCompile("(t%[0-9]+)")
+ groupLenRegex = regexp.MustCompile(",([0-9#]+)\\.")
+ secondaryGroupLenRegex = regexp.MustCompile(",([0-9#]+),")
+ requiredNumRegex = regexp.MustCompile("([0-9]+)\\.")
+ requiredDecimalRegex = regexp.MustCompile("\\.([0-9]+)")
)
type translator struct {
@@ -56,15 +57,22 @@ type translator struct {
OrdinalFunc string
RangeFunc string
Decimal string
+ DecimalLen int
Group string
+ GroupLen int
Minus string
+ MinusLen int
Percent string
PerMille string
Currencies string
// FmtNumberFunc string
- FmtNumberExists bool
- FmtNumberGroupLen int
- FmtNumberMinDecimalLen int
+ FmtNumberExists bool
+ FmtNumberPrefix string
+ FmtNumberSuffix string
+
+ FmtNumberGroupLen int
+ FmtNumberSecondaryGroupLen int
+ FmtNumberMinDecimalLen int
// calculation only fields
DecimalNumberFormat string
@@ -189,10 +197,12 @@ func postProcess(cldr *cldr.CLDR) {
if len(trans.Decimal) == 0 {
if found {
+ trans.DecimalLen = base.DecimalLen
trans.Decimal = base.Decimal
}
if len(trans.Decimal) == 0 {
+ trans.DecimalLen = 0
trans.Decimal = "[]byte{}"
}
}
@@ -200,10 +210,12 @@ func postProcess(cldr *cldr.CLDR) {
if len(trans.Group) == 0 {
if found {
+ trans.GroupLen = base.GroupLen
trans.Group = base.Group
}
if len(trans.Group) == 0 {
+ trans.GroupLen = 0
trans.Group = "[]byte{}"
}
}
@@ -211,10 +223,12 @@ func postProcess(cldr *cldr.CLDR) {
if len(trans.Minus) == 0 {
if found {
+ trans.MinusLen = base.MinusLen
trans.Minus = base.Minus
}
if len(trans.Minus) == 0 {
+ trans.MinusLen = 0
trans.Minus = "[]byte{}"
}
}
@@ -325,13 +339,19 @@ func preProcess(cldr *cldr.CLDR) {
symbol := ldml.Numbers.Symbols[0]
if len(symbol.Decimal) > 0 {
- trans.Decimal = fmt.Sprintf("%#v", []byte(symbol.Decimal[0].Data()))
+ b := []byte(symbol.Decimal[0].Data())
+ trans.DecimalLen = len(b)
+ trans.Decimal = fmt.Sprintf("%#v", b)
}
if len(symbol.Group) > 0 {
- trans.Group = fmt.Sprintf("%#v", []byte(symbol.Group[0].Data()))
+ b := []byte(symbol.Group[0].Data())
+ trans.GroupLen = len(b)
+ trans.Group = fmt.Sprintf("%#v", b)
}
if len(symbol.MinusSign) > 0 {
- trans.Minus = fmt.Sprintf("%#v", []byte(symbol.MinusSign[0].Data()))
+ b := []byte(symbol.MinusSign[0].Data())
+ trans.MinusLen = len(b)
+ trans.Minus = fmt.Sprintf("%#v", b)
}
if len(symbol.PercentSign) > 0 {
trans.Percent = fmt.Sprintf("%#v", []byte(symbol.PercentSign[0].Data()))
@@ -409,16 +429,54 @@ func parseDecimalNumberFormat(trans *translator) (results string) {
trans.FmtNumberExists = true
- match := groupLenRegex.FindString(trans.DecimalNumberFormat)
+ formats := strings.SplitN(trans.DecimalNumberFormat, ";", 2)
+
+ // if len(formats) > 1 {
+ // trans.FmtNumberHasNegativeFormat = true
+ // }
+
+ match := groupLenRegex.FindString(formats[0])
if len(match) > 0 {
trans.FmtNumberGroupLen = len(match) - 2
}
- match = requiredDecimalRegex.FindString(trans.DecimalNumberFormat)
+ match = requiredDecimalRegex.FindString(formats[0])
if len(match) > 0 {
trans.FmtNumberMinDecimalLen = len(match) - 1
}
+ match = secondaryGroupLenRegex.FindString(formats[0])
+ if len(match) > 0 {
+ trans.FmtNumberSecondaryGroupLen = len(match) - 2
+ }
+
+ // start := 0
+ // // prefix := ""
+
+ // // positive prefix
+ // for start = 0; start < len(formats[0]); start++ {
+ // if formats[0][start] == '#' || formats[0][start] == '0' {
+ // break
+ // }
+ // }
+
+ // // if start > 0 {
+ // // prefix = formats[0][:start]
+ // // }
+
+ // end := 0
+
+ // // positive prefix
+ // for end = len(formats[0]) - 1; end >= 0; end-- {
+ // if formats[0][end] == '#' || formats[0][end] == '0' {
+ // end++
+ // break
+ // }
+ // }
+
+ // fmt.Println(start)
+ // fmt.Println(end)
+
return
}
diff --git a/cmd/translator.tmpl b/cmd/translator.tmpl
index b4c31b78..96a75bea 100644
--- a/cmd/translator.tmpl
+++ b/cmd/translator.tmpl
@@ -69,12 +69,16 @@ func({{ .BaseLocale }} *{{ .Locale }}) RangePluralRule(num1 float64, v1 uint64,n
// avoid allocations; otherwise just cast as string.
func({{ .BaseLocale }} *{{ .Locale }}) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
- {{ if eq .FmtNumberExists true }}
- {{ if gt .FmtNumberGroupLen 0 }}
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
+ {{- if eq .FmtNumberExists true }}
+ {{- if gt .FmtNumberGroupLen 0 }}
l := len(s) + len({{ .BaseLocale }}.decimal) + len({{ .BaseLocale }}.group) * len(s[:len(s)-int(v)-1]) / {{ .FmtNumberGroupLen }}
count := 0
inWhole := v == 0
+ {{- if gt .FmtNumberSecondaryGroupLen 0}}
+ inSecondary := false
+ groupThreshold := {{ .FmtNumberGroupLen }}
+ {{ end -}}
{{ else }}
l := len(s) + len({{ .BaseLocale }}.decimal)
{{ end }}
@@ -84,11 +88,14 @@ func({{ .BaseLocale }} *{{ .Locale }}) FmtNumber(num float64, v uint64) []byte {
if s[i] == '.' {
+ {{- if eq .DecimalLen 1 }}
+ b = append(b, {{ .BaseLocale }}.decimal[0])
+ {{- else }}
for j := len({{ .BaseLocale }}.decimal) - 1; j >= 0; j-- {
b = append(b, {{ .BaseLocale }}.decimal[j])
}
-
- {{ if gt .FmtNumberGroupLen 0 }}
+ {{ end -}}
+ {{- if gt .FmtNumberGroupLen 0 }}
inWhole = true
{{ end }}
continue
@@ -97,13 +104,33 @@ func({{ .BaseLocale }} *{{ .Locale }}) FmtNumber(num float64, v uint64) []byte {
{{ if gt .FmtNumberGroupLen 0 }}
if inWhole {
- if count == {{ .FmtNumberGroupLen }} {
-
+ {{- if gt .FmtNumberSecondaryGroupLen 0}}
+
+ if count == groupThreshold {
+ {{- if eq .GroupLen 1 }}
+ b = append(b, {{ .BaseLocale }}.group[0])
+ {{- else }}
for j := len({{ .BaseLocale }}.group) - 1; j >= 0; j-- {
b = append(b, {{ .BaseLocale }}.group[j])
}
+ {{ end }}
+ count = 1
+ if !inSecondary {
+ inSecondary = true
+ groupThreshold = {{ .FmtNumberSecondaryGroupLen }}
+ }
+ {{ else }}
+ if count == {{ .FmtNumberGroupLen }} {
+ {{- if eq .GroupLen 1 }}
+ b = append(b, {{ .BaseLocale }}.group[0])
+ {{- else }}
+ for j := len({{ .BaseLocale }}.group) - 1; j >= 0; j-- {
+ b = append(b, {{ .BaseLocale }}.group[j])
+ }
+ {{ end }}
count = 1
+ {{ end -}}
} else {
count++
}
@@ -114,6 +141,16 @@ func({{ .BaseLocale }} *{{ .Locale }}) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ {{- if eq .MinusLen 1 }}
+ b = append(b, {{ .BaseLocale }}.minus[0])
+ {{ else }}
+ for j := len({{ .BaseLocale }}.minus) - 1; j >= 0; j-- {
+ b = append(b, {{ .BaseLocale }}.minus[j])
+ }
+ {{ end -}}
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
@@ -135,7 +172,7 @@ func({{ .BaseLocale }} *{{ .Locale }}) FmtNumber(num float64, v uint64) []byte {
return b
{{ else }}
return []byte(s)
- {{ end }}
+ {{ end -}}
}
{{ end }} \ No newline at end of file
diff --git a/cs/cs.go b/cs/cs.go
index d01751f0..6447975c 100644
--- a/cs/cs.go
+++ b/cs/cs.go
@@ -114,19 +114,15 @@ func (cs *cs) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (cs *cs) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(cs.decimal) + len(cs.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(cs.decimal) - 1; j >= 0; j-- {
b = append(b, cs.decimal[j])
}
@@ -137,9 +133,7 @@ func (cs *cs) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(cs.group) - 1; j >= 0; j-- {
b = append(b, cs.group[j])
}
@@ -153,11 +147,16 @@ func (cs *cs) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(cs.minus) - 1; j >= 0; j-- {
+ b = append(b, cs.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/cs_CZ/cs_CZ.go b/cs_CZ/cs_CZ.go
index 1cb14b64..84b4bb7f 100644
--- a/cs_CZ/cs_CZ.go
+++ b/cs_CZ/cs_CZ.go
@@ -114,19 +114,15 @@ func (cs *cs_CZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (cs *cs_CZ) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(cs.decimal) + len(cs.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(cs.decimal) - 1; j >= 0; j-- {
b = append(b, cs.decimal[j])
}
@@ -137,9 +133,7 @@ func (cs *cs_CZ) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(cs.group) - 1; j >= 0; j-- {
b = append(b, cs.group[j])
}
@@ -153,11 +147,16 @@ func (cs *cs_CZ) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(cs.minus) - 1; j >= 0; j-- {
+ b = append(b, cs.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/cu/cu.go b/cu/cu.go
index 6376ec84..f6316b8a 100644
--- a/cu/cu.go
+++ b/cu/cu.go
@@ -1,6 +1,7 @@
package cu
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,32 +69,23 @@ func (cu *cu) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (cu *cu) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(cu.decimal) + len(cu.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(cu.decimal) - 1; j >= 0; j-- {
- b = append(b, cu.decimal[j])
- }
-
+ b = append(b, cu.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(cu.group) - 1; j >= 0; j-- {
b = append(b, cu.group[j])
}
@@ -107,11 +99,14 @@ func (cu *cu) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, cu.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/cu_RU/cu_RU.go b/cu_RU/cu_RU.go
index 0250318d..534832dc 100644
--- a/cu_RU/cu_RU.go
+++ b/cu_RU/cu_RU.go
@@ -1,6 +1,7 @@
package cu_RU
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,32 +69,23 @@ func (cu *cu_RU) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (cu *cu_RU) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(cu.decimal) + len(cu.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(cu.decimal) - 1; j >= 0; j-- {
- b = append(b, cu.decimal[j])
- }
-
+ b = append(b, cu.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(cu.group) - 1; j >= 0; j-- {
b = append(b, cu.group[j])
}
@@ -107,11 +99,14 @@ func (cu *cu_RU) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, cu.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/cy/cy.go b/cy/cy.go
index 154e0dad..ef1cd823 100644
--- a/cy/cy.go
+++ b/cy/cy.go
@@ -30,7 +30,7 @@ func New() locales.Translator {
minus: []byte{},
percent: []byte{},
perMille: []byte{},
- currencies: [][]uint8{{0x41, 0x44, 0x50}, {0x41, 0x45, 0x44}, {0x41, 0x46, 0x41}, {0x41, 0x46, 0x4e}, {0x41, 0x4c, 0x4b}, {0x41, 0x4c, 0x4c}, {0x41, 0x4d, 0x44}, {0x41, 0x4e, 0x47}, {0x41, 0x4f, 0x41}, {0x41, 0x4f, 0x4b}, {0x41, 0x4f, 0x4e}, {0x41, 0x4f, 0x52}, {0x41, 0x52, 0x41}, {0x41, 0x52, 0x4c}, {0x41, 0x52, 0x4d}, {0x41, 0x52, 0x50}, {0x41, 0x52, 0x53}, {0x41, 0x54, 0x53}, {0x41, 0x24}, {0x41, 0x57, 0x47}, {0x41, 0x5a, 0x4d}, {0x41, 0x5a, 0x4e}, {0x42, 0x41, 0x44}, {0x42, 0x41, 0x4d}, {0x42, 0x41, 0x4e}, {0x42, 0x42, 0x44}, {0x42, 0x44, 0x54}, {0x42, 0x45, 0x43}, {0x42, 0x45, 0x46}, {0x42, 0x45, 0x4c}, {0x42, 0x47, 0x4c}, {0x42, 0x47, 0x4d}, {0x42, 0x47, 0x4e}, {0x42, 0x47, 0x4f}, {0x42, 0x48, 0x44}, {0x42, 0x49, 0x46}, {0x42, 0x4d, 0x44}, {0x42, 0x4e, 0x44}, {0x42, 0x4f, 0x42}, {0x42, 0x4f, 0x4c}, {0x42, 0x4f, 0x50}, {0x42, 0x4f, 0x56}, {0x42, 0x52, 0x42}, {0x42, 0x52, 0x43}, {0x42, 0x52, 0x45}, {0x52, 0x24}, {0x42, 0x52, 0x4e}, {0x42, 0x52, 0x52}, {0x42, 0x52, 0x5a}, {0x42, 0x53, 0x44}, {0x42, 0x54, 0x4e}, {0x42, 0x55, 0x4b}, {0x42, 0x57, 0x50}, {0x42, 0x59, 0x42}, {0x42, 0x59, 0x52}, {0x42, 0x5a, 0x44}, {0x43, 0x41, 0x24}, {0x43, 0x44, 0x46}, {0x43, 0x48, 0x45}, {0x43, 0x48, 0x46}, {0x43, 0x48, 0x57}, {0x43, 0x4c, 0x45}, {0x43, 0x4c, 0x46}, {0x43, 0x4c, 0x50}, {0x43, 0x4e, 0x58}, {0x43, 0x4e, 0xc2, 0xa5}, {0x43, 0x4f, 0x50}, {0x43, 0x4f, 0x55}, {0x43, 0x52, 0x43}, {0x43, 0x53, 0x44}, {0x43, 0x53, 0x4b}, {0x43, 0x55, 0x43}, {0x43, 0x55, 0x50}, {0x43, 0x56, 0x45}, {0x43, 0x59, 0x50}, {0x43, 0x5a, 0x4b}, {0x44, 0x44, 0x4d}, {0x44, 0x45, 0x4d}, {0x44, 0x4a, 0x46}, {0x44, 0x4b, 0x4b}, {0x44, 0x4f, 0x50}, {0x44, 0x5a, 0x44}, {0x45, 0x43, 0x53}, {0x45, 0x43, 0x56}, {0x45, 0x45, 0x4b}, {0x45, 0x47, 0x50}, {0x45, 0x52, 0x4e}, {0x45, 0x53, 0x41}, {0x45, 0x53, 0x42}, {0x45, 0x53, 0x50}, {0x45, 0x54, 0x42}, {0xe2, 0x82, 0xac}, {0x46, 0x49, 0x4d}, {0x46, 0x4a, 0x44}, {0x46, 0x4b, 0x50}, {0x46, 0x52, 0x46}, {0xc2, 0xa3}, {0x47, 0x45, 0x4b}, {0x47, 0x45, 0x4c}, {0x47, 0x48, 0x43}, {0x47, 0x48, 0x53}, {0x47, 0x49, 0x50}, {0x47, 0x4d, 0x44}, {0x47, 0x4e, 0x46}, {0x47, 0x4e, 0x53}, {0x47, 0x51, 0x45}, {0x47, 0x52, 0x44}, {0x47, 0x54, 0x51}, {0x47, 0x57, 0x45}, {0x47, 0x57, 0x50}, {0x47, 0x59, 0x44}, {0x48, 0x4b, 0x24}, {0x48, 0x4e, 0x4c}, {0x48, 0x52, 0x44}, {0x48, 0x52, 0x4b}, {0x48, 0x54, 0x47}, {0x48, 0x55, 0x46}, {0x49, 0x44, 0x52}, {0x49, 0x45, 0x50}, {0x49, 0x4c, 0x50}, {0x49, 0x4c, 0x52}, {0xe2, 0x82, 0xaa}, {0xe2, 0x82, 0xb9}, {0x49, 0x51, 0x44}, {0x49, 0x52, 0x52}, {0x49, 0x53, 0x4a}, {0x49, 0x53, 0x4b}, {0x49, 0x54, 0x4c}, {0x4a, 0x4d, 0x44}, {0x4a, 0x4f, 0x44}, {0x4a, 0x50, 0xc2, 0xa5}, {0x4b, 0x45, 0x53}, {0x4b, 0x47, 0x53}, {0x4b, 0x48, 0x52}, {0x4b, 0x4d, 0x46}, {0x4b, 0x50, 0x57}, {0x4b, 0x52, 0x48}, {0x4b, 0x52, 0x4f}, {0x4b, 0x52, 0x57}, {0x4b, 0x57, 0x44}, {0x4b, 0x59, 0x44}, {0x4b, 0x5a, 0x54}, {0x4c, 0x41, 0x4b}, {0x4c, 0x42, 0x50}, {0x4c, 0x4b, 0x52}, {0x4c, 0x52, 0x44}, {0x4c, 0x53, 0x4c}, {0x4c, 0x54, 0x4c}, {0x4c, 0x54, 0x54}, {0x4c, 0x55, 0x43}, {0x4c, 0x55, 0x46}, {0x4c, 0x55, 0x4c}, {0x4c, 0x56, 0x4c}, {0x4c, 0x56, 0x52}, {0x4c, 0x59, 0x44}, {0x4d, 0x41, 0x44}, {0x4d, 0x41, 0x46}, {0x4d, 0x43, 0x46}, {0x4d, 0x44, 0x43}, {0x4d, 0x44, 0x4c}, {0x4d, 0x47, 0x41}, {0x4d, 0x47, 0x46}, {0x4d, 0x4b, 0x44}, {0x4d, 0x4b, 0x4e}, {0x4d, 0x4c, 0x46}, {0x4d, 0x4d, 0x4b}, {0x4d, 0x4e, 0x54}, {0x4d, 0x4f, 0x50}, {0x4d, 0x52, 0x4f}, {0x4d, 0x54, 0x4c}, {0x4d, 0x54, 0x50}, {0x4d, 0x55, 0x52}, {0x4d, 0x56, 0x50}, {0x4d, 0x56, 0x52}, {0x4d, 0x57, 0x4b}, {0x4d, 0x58, 0x24}, {0x4d, 0x58, 0x50}, {0x4d, 0x58, 0x56}, {0x4d, 0x59, 0x52}, {0x4d, 0x5a, 0x45}, {0x4d, 0x5a, 0x4d}, {0x4d, 0x5a, 0x4e}, {0x4e, 0x41, 0x44}, {0x4e, 0x47, 0x4e}, {0x4e, 0x49, 0x43}, {0x4e, 0x49, 0x4f}, {0x4e, 0x4c, 0x47}, {0x4e, 0x4f, 0x4b}, {0x4e, 0x50, 0x52}, {0x4e, 0x5a, 0x24}, {0x4f, 0x4d, 0x52}, {0x50, 0x41, 0x42}, {0x50, 0x45, 0x49}, {0x50, 0x45, 0x4e}, {0x50, 0x45, 0x53}, {0x50, 0x47, 0x4b}, {0x50, 0x48, 0x50}, {0x50, 0x4b, 0x52}, {0x50, 0x4c, 0x4e}, {0x50, 0x4c, 0x5a}, {0x50, 0x54, 0x45}, {0x50, 0x59, 0x47}, {0x51, 0x41, 0x52}, {0x52, 0x48, 0x44}, {0x52, 0x4f, 0x4c}, {0x52, 0x4f, 0x4e}, {0x52, 0x53, 0x44}, {0x52, 0x55, 0x42}, {0x52, 0x55, 0x52}, {0x52, 0x57, 0x46}, {0x53, 0x41, 0x52}, {0x53, 0x42, 0x44}, {0x53, 0x43, 0x52}, {0x53, 0x44, 0x44}, {0x53, 0x44, 0x47}, {0x53, 0x44, 0x50}, {0x53, 0x45, 0x4b}, {0x53, 0x47, 0x44}, {0x53, 0x48, 0x50}, {0x53, 0x49, 0x54}, {0x53, 0x4b, 0x4b}, {0x53, 0x4c, 0x4c}, {0x53, 0x4f, 0x53}, {0x53, 0x52, 0x44}, {0x53, 0x52, 0x47}, {0x53, 0x53, 0x50}, {0x53, 0x54, 0x44}, {0x53, 0x55, 0x52}, {0x53, 0x56, 0x43}, {0x53, 0x59, 0x50}, {0x53, 0x5a, 0x4c}, {0xe0, 0xb8, 0xbf}, {0x54, 0x4a, 0x52}, {0x54, 0x4a, 0x53}, {0x54, 0x4d, 0x4d}, {0x54, 0x4d, 0x54}, {0x54, 0x4e, 0x44}, {0x54, 0x4f, 0x50}, {0x54, 0x50, 0x45}, {0x54, 0x52, 0x4c}, {0x54, 0x52, 0x59}, {0x54, 0x54, 0x44}, {0x4e, 0x54, 0x24}, {0x54, 0x5a, 0x53}, {0x55, 0x41, 0x48}, {0x55, 0x41, 0x4b}, {0x55, 0x47, 0x53}, {0x55, 0x47, 0x58}, {0x55, 0x53, 0x24}, {0x55, 0x53, 0x4e}, {0x55, 0x53, 0x53}, {0x55, 0x59, 0x49}, {0x55, 0x59, 0x50}, {0x55, 0x59, 0x55}, {0x55, 0x5a, 0x53}, {0x56, 0x45, 0x42}, {0x56, 0x45, 0x46}, {0xe2, 0x82, 0xab}, {0x56, 0x4e, 0x4e}, {0x56, 0x55, 0x56}, {0x57, 0x53, 0x54}, {0x46, 0x43, 0x46, 0x41}, {0x58, 0x41, 0x47}, {0x58, 0x41, 0x55}, {0x58, 0x42, 0x41}, {0x58, 0x42, 0x42}, {0x58, 0x42, 0x43}, {0x58, 0x42, 0x44}, {0x45, 0x43, 0x24}, {0x58, 0x44, 0x52}, {0x58, 0x45, 0x55}, {0x58, 0x46, 0x4f}, {0x58, 0x46, 0x55}, {0x43, 0x46, 0x41}, {0x58, 0x50, 0x44}, {0x43, 0x46, 0x50, 0x46}, {0x58, 0x50, 0x54}, {0x58, 0x52, 0x45}, {0x58, 0x53, 0x55}, {0x58, 0x54, 0x53}, {0x58, 0x55, 0x41}, {0x58, 0x58, 0x58}, {0x59, 0x44, 0x44}, {0x59, 0x45, 0x52}, {0x59, 0x55, 0x44}, {0x59, 0x55, 0x4d}, {0x59, 0x55, 0x4e}, {0x59, 0x55, 0x52}, {0x5a, 0x41, 0x4c}, {0x5a, 0x41, 0x52}, {0x5a, 0x4d, 0x4b}, {0x5a, 0x4d, 0x57}, {0x5a, 0x52, 0x4e}, {0x5a, 0x52, 0x5a}, {0x5a, 0x57, 0x44}, {0x5a, 0x57, 0x4c}, {0x5a, 0x57, 0x52}},
+ currencies: [][]uint8{[]uint8{0x41, 0x44, 0x50}, []uint8{0x41, 0x45, 0x44}, []uint8{0x41, 0x46, 0x41}, []uint8{0x41, 0x46, 0x4e}, []uint8{0x41, 0x4c, 0x4b}, []uint8{0x41, 0x4c, 0x4c}, []uint8{0x41, 0x4d, 0x44}, []uint8{0x41, 0x4e, 0x47}, []uint8{0x41, 0x4f, 0x41}, []uint8{0x41, 0x4f, 0x4b}, []uint8{0x41, 0x4f, 0x4e}, []uint8{0x41, 0x4f, 0x52}, []uint8{0x41, 0x52, 0x41}, []uint8{0x41, 0x52, 0x4c}, []uint8{0x41, 0x52, 0x4d}, []uint8{0x41, 0x52, 0x50}, []uint8{0x41, 0x52, 0x53}, []uint8{0x41, 0x54, 0x53}, []uint8{0x41, 0x24}, []uint8{0x41, 0x57, 0x47}, []uint8{0x41, 0x5a, 0x4d}, []uint8{0x41, 0x5a, 0x4e}, []uint8{0x42, 0x41, 0x44}, []uint8{0x42, 0x41, 0x4d}, []uint8{0x42, 0x41, 0x4e}, []uint8{0x42, 0x42, 0x44}, []uint8{0x42, 0x44, 0x54}, []uint8{0x42, 0x45, 0x43}, []uint8{0x42, 0x45, 0x46}, []uint8{0x42, 0x45, 0x4c}, []uint8{0x42, 0x47, 0x4c}, []uint8{0x42, 0x47, 0x4d}, []uint8{0x42, 0x47, 0x4e}, []uint8{0x42, 0x47, 0x4f}, []uint8{0x42, 0x48, 0x44}, []uint8{0x42, 0x49, 0x46}, []uint8{0x42, 0x4d, 0x44}, []uint8{0x42, 0x4e, 0x44}, []uint8{0x42, 0x4f, 0x42}, []uint8{0x42, 0x4f, 0x4c}, []uint8{0x42, 0x4f, 0x50}, []uint8{0x42, 0x4f, 0x56}, []uint8{0x42, 0x52, 0x42}, []uint8{0x42, 0x52, 0x43}, []uint8{0x42, 0x52, 0x45}, []uint8{0x52, 0x24}, []uint8{0x42, 0x52, 0x4e}, []uint8{0x42, 0x52, 0x52}, []uint8{0x42, 0x52, 0x5a}, []uint8{0x42, 0x53, 0x44}, []uint8{0x42, 0x54, 0x4e}, []uint8{0x42, 0x55, 0x4b}, []uint8{0x42, 0x57, 0x50}, []uint8{0x42, 0x59, 0x42}, []uint8{0x42, 0x59, 0x52}, []uint8{0x42, 0x5a, 0x44}, []uint8{0x43, 0x41, 0x24}, []uint8{0x43, 0x44, 0x46}, []uint8{0x43, 0x48, 0x45}, []uint8{0x43, 0x48, 0x46}, []uint8{0x43, 0x48, 0x57}, []uint8{0x43, 0x4c, 0x45}, []uint8{0x43, 0x4c, 0x46}, []uint8{0x43, 0x4c, 0x50}, []uint8{0x43, 0x4e, 0x58}, []uint8{0x43, 0x4e, 0xc2, 0xa5}, []uint8{0x43, 0x4f, 0x50}, []uint8{0x43, 0x4f, 0x55}, []uint8{0x43, 0x52, 0x43}, []uint8{0x43, 0x53, 0x44}, []uint8{0x43, 0x53, 0x4b}, []uint8{0x43, 0x55, 0x43}, []uint8{0x43, 0x55, 0x50}, []uint8{0x43, 0x56, 0x45}, []uint8{0x43, 0x59, 0x50}, []uint8{0x43, 0x5a, 0x4b}, []uint8{0x44, 0x44, 0x4d}, []uint8{0x44, 0x45, 0x4d}, []uint8{0x44, 0x4a, 0x46}, []uint8{0x44, 0x4b, 0x4b}, []uint8{0x44, 0x4f, 0x50}, []uint8{0x44, 0x5a, 0x44}, []uint8{0x45, 0x43, 0x53}, []uint8{0x45, 0x43, 0x56}, []uint8{0x45, 0x45, 0x4b}, []uint8{0x45, 0x47, 0x50}, []uint8{0x45, 0x52, 0x4e}, []uint8{0x45, 0x53, 0x41}, []uint8{0x45, 0x53, 0x42}, []uint8{0x45, 0x53, 0x50}, []uint8{0x45, 0x54, 0x42}, []uint8{0xe2, 0x82, 0xac}, []uint8{0x46, 0x49, 0x4d}, []uint8{0x46, 0x4a, 0x44}, []uint8{0x46, 0x4b, 0x50}, []uint8{0x46, 0x52, 0x46}, []uint8{0xc2, 0xa3}, []uint8{0x47, 0x45, 0x4b}, []uint8{0x47, 0x45, 0x4c}, []uint8{0x47, 0x48, 0x43}, []uint8{0x47, 0x48, 0x53}, []uint8{0x47, 0x49, 0x50}, []uint8{0x47, 0x4d, 0x44}, []uint8{0x47, 0x4e, 0x46}, []uint8{0x47, 0x4e, 0x53}, []uint8{0x47, 0x51, 0x45}, []uint8{0x47, 0x52, 0x44}, []uint8{0x47, 0x54, 0x51}, []uint8{0x47, 0x57, 0x45}, []uint8{0x47, 0x57, 0x50}, []uint8{0x47, 0x59, 0x44}, []uint8{0x48, 0x4b, 0x24}, []uint8{0x48, 0x4e, 0x4c}, []uint8{0x48, 0x52, 0x44}, []uint8{0x48, 0x52, 0x4b}, []uint8{0x48, 0x54, 0x47}, []uint8{0x48, 0x55, 0x46}, []uint8{0x49, 0x44, 0x52}, []uint8{0x49, 0x45, 0x50}, []uint8{0x49, 0x4c, 0x50}, []uint8{0x49, 0x4c, 0x52}, []uint8{0xe2, 0x82, 0xaa}, []uint8{0xe2, 0x82, 0xb9}, []uint8{0x49, 0x51, 0x44}, []uint8{0x49, 0x52, 0x52}, []uint8{0x49, 0x53, 0x4a}, []uint8{0x49, 0x53, 0x4b}, []uint8{0x49, 0x54, 0x4c}, []uint8{0x4a, 0x4d, 0x44}, []uint8{0x4a, 0x4f, 0x44}, []uint8{0x4a, 0x50, 0xc2, 0xa5}, []uint8{0x4b, 0x45, 0x53}, []uint8{0x4b, 0x47, 0x53}, []uint8{0x4b, 0x48, 0x52}, []uint8{0x4b, 0x4d, 0x46}, []uint8{0x4b, 0x50, 0x57}, []uint8{0x4b, 0x52, 0x48}, []uint8{0x4b, 0x52, 0x4f}, []uint8{0x4b, 0x52, 0x57}, []uint8{0x4b, 0x57, 0x44}, []uint8{0x4b, 0x59, 0x44}, []uint8{0x4b, 0x5a, 0x54}, []uint8{0x4c, 0x41, 0x4b}, []uint8{0x4c, 0x42, 0x50}, []uint8{0x4c, 0x4b, 0x52}, []uint8{0x4c, 0x52, 0x44}, []uint8{0x4c, 0x53, 0x4c}, []uint8{0x4c, 0x54, 0x4c}, []uint8{0x4c, 0x54, 0x54}, []uint8{0x4c, 0x55, 0x43}, []uint8{0x4c, 0x55, 0x46}, []uint8{0x4c, 0x55, 0x4c}, []uint8{0x4c, 0x56, 0x4c}, []uint8{0x4c, 0x56, 0x52}, []uint8{0x4c, 0x59, 0x44}, []uint8{0x4d, 0x41, 0x44}, []uint8{0x4d, 0x41, 0x46}, []uint8{0x4d, 0x43, 0x46}, []uint8{0x4d, 0x44, 0x43}, []uint8{0x4d, 0x44, 0x4c}, []uint8{0x4d, 0x47, 0x41}, []uint8{0x4d, 0x47, 0x46}, []uint8{0x4d, 0x4b, 0x44}, []uint8{0x4d, 0x4b, 0x4e}, []uint8{0x4d, 0x4c, 0x46}, []uint8{0x4d, 0x4d, 0x4b}, []uint8{0x4d, 0x4e, 0x54}, []uint8{0x4d, 0x4f, 0x50}, []uint8{0x4d, 0x52, 0x4f}, []uint8{0x4d, 0x54, 0x4c}, []uint8{0x4d, 0x54, 0x50}, []uint8{0x4d, 0x55, 0x52}, []uint8{0x4d, 0x56, 0x50}, []uint8{0x4d, 0x56, 0x52}, []uint8{0x4d, 0x57, 0x4b}, []uint8{0x4d, 0x58, 0x24}, []uint8{0x4d, 0x58, 0x50}, []uint8{0x4d, 0x58, 0x56}, []uint8{0x4d, 0x59, 0x52}, []uint8{0x4d, 0x5a, 0x45}, []uint8{0x4d, 0x5a, 0x4d}, []uint8{0x4d, 0x5a, 0x4e}, []uint8{0x4e, 0x41, 0x44}, []uint8{0x4e, 0x47, 0x4e}, []uint8{0x4e, 0x49, 0x43}, []uint8{0x4e, 0x49, 0x4f}, []uint8{0x4e, 0x4c, 0x47}, []uint8{0x4e, 0x4f, 0x4b}, []uint8{0x4e, 0x50, 0x52}, []uint8{0x4e, 0x5a, 0x24}, []uint8{0x4f, 0x4d, 0x52}, []uint8{0x50, 0x41, 0x42}, []uint8{0x50, 0x45, 0x49}, []uint8{0x50, 0x45, 0x4e}, []uint8{0x50, 0x45, 0x53}, []uint8{0x50, 0x47, 0x4b}, []uint8{0x50, 0x48, 0x50}, []uint8{0x50, 0x4b, 0x52}, []uint8{0x50, 0x4c, 0x4e}, []uint8{0x50, 0x4c, 0x5a}, []uint8{0x50, 0x54, 0x45}, []uint8{0x50, 0x59, 0x47}, []uint8{0x51, 0x41, 0x52}, []uint8{0x52, 0x48, 0x44}, []uint8{0x52, 0x4f, 0x4c}, []uint8{0x52, 0x4f, 0x4e}, []uint8{0x52, 0x53, 0x44}, []uint8{0x52, 0x55, 0x42}, []uint8{0x52, 0x55, 0x52}, []uint8{0x52, 0x57, 0x46}, []uint8{0x53, 0x41, 0x52}, []uint8{0x53, 0x42, 0x44}, []uint8{0x53, 0x43, 0x52}, []uint8{0x53, 0x44, 0x44}, []uint8{0x53, 0x44, 0x47}, []uint8{0x53, 0x44, 0x50}, []uint8{0x53, 0x45, 0x4b}, []uint8{0x53, 0x47, 0x44}, []uint8{0x53, 0x48, 0x50}, []uint8{0x53, 0x49, 0x54}, []uint8{0x53, 0x4b, 0x4b}, []uint8{0x53, 0x4c, 0x4c}, []uint8{0x53, 0x4f, 0x53}, []uint8{0x53, 0x52, 0x44}, []uint8{0x53, 0x52, 0x47}, []uint8{0x53, 0x53, 0x50}, []uint8{0x53, 0x54, 0x44}, []uint8{0x53, 0x55, 0x52}, []uint8{0x53, 0x56, 0x43}, []uint8{0x53, 0x59, 0x50}, []uint8{0x53, 0x5a, 0x4c}, []uint8{0xe0, 0xb8, 0xbf}, []uint8{0x54, 0x4a, 0x52}, []uint8{0x54, 0x4a, 0x53}, []uint8{0x54, 0x4d, 0x4d}, []uint8{0x54, 0x4d, 0x54}, []uint8{0x54, 0x4e, 0x44}, []uint8{0x54, 0x4f, 0x50}, []uint8{0x54, 0x50, 0x45}, []uint8{0x54, 0x52, 0x4c}, []uint8{0x54, 0x52, 0x59}, []uint8{0x54, 0x54, 0x44}, []uint8{0x4e, 0x54, 0x24}, []uint8{0x54, 0x5a, 0x53}, []uint8{0x55, 0x41, 0x48}, []uint8{0x55, 0x41, 0x4b}, []uint8{0x55, 0x47, 0x53}, []uint8{0x55, 0x47, 0x58}, []uint8{0x55, 0x53, 0x24}, []uint8{0x55, 0x53, 0x4e}, []uint8{0x55, 0x53, 0x53}, []uint8{0x55, 0x59, 0x49}, []uint8{0x55, 0x59, 0x50}, []uint8{0x55, 0x59, 0x55}, []uint8{0x55, 0x5a, 0x53}, []uint8{0x56, 0x45, 0x42}, []uint8{0x56, 0x45, 0x46}, []uint8{0xe2, 0x82, 0xab}, []uint8{0x56, 0x4e, 0x4e}, []uint8{0x56, 0x55, 0x56}, []uint8{0x57, 0x53, 0x54}, []uint8{0x46, 0x43, 0x46, 0x41}, []uint8{0x58, 0x41, 0x47}, []uint8{0x58, 0x41, 0x55}, []uint8{0x58, 0x42, 0x41}, []uint8{0x58, 0x42, 0x42}, []uint8{0x58, 0x42, 0x43}, []uint8{0x58, 0x42, 0x44}, []uint8{0x45, 0x43, 0x24}, []uint8{0x58, 0x44, 0x52}, []uint8{0x58, 0x45, 0x55}, []uint8{0x58, 0x46, 0x4f}, []uint8{0x58, 0x46, 0x55}, []uint8{0x43, 0x46, 0x41}, []uint8{0x58, 0x50, 0x44}, []uint8{0x43, 0x46, 0x50, 0x46}, []uint8{0x58, 0x50, 0x54}, []uint8{0x58, 0x52, 0x45}, []uint8{0x58, 0x53, 0x55}, []uint8{0x58, 0x54, 0x53}, []uint8{0x58, 0x55, 0x41}, []uint8{0x58, 0x58, 0x58}, []uint8{0x59, 0x44, 0x44}, []uint8{0x59, 0x45, 0x52}, []uint8{0x59, 0x55, 0x44}, []uint8{0x59, 0x55, 0x4d}, []uint8{0x59, 0x55, 0x4e}, []uint8{0x59, 0x55, 0x52}, []uint8{0x5a, 0x41, 0x4c}, []uint8{0x5a, 0x41, 0x52}, []uint8{0x5a, 0x4d, 0x4b}, []uint8{0x5a, 0x4d, 0x57}, []uint8{0x5a, 0x52, 0x4e}, []uint8{0x5a, 0x52, 0x5a}, []uint8{0x5a, 0x57, 0x44}, []uint8{0x5a, 0x57, 0x4c}, []uint8{0x5a, 0x57, 0x52}},
}
}
@@ -144,19 +144,15 @@ func (cy *cy) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (cy *cy) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(cy.decimal) + len(cy.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(cy.decimal) - 1; j >= 0; j-- {
b = append(b, cy.decimal[j])
}
@@ -167,9 +163,7 @@ func (cy *cy) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(cy.group) - 1; j >= 0; j-- {
b = append(b, cy.group[j])
}
@@ -183,11 +177,16 @@ func (cy *cy) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(cy.minus) - 1; j >= 0; j-- {
+ b = append(b, cy.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/cy_GB/cy_GB.go b/cy_GB/cy_GB.go
index 71cb67af..b2142ef8 100644
--- a/cy_GB/cy_GB.go
+++ b/cy_GB/cy_GB.go
@@ -144,19 +144,15 @@ func (cy *cy_GB) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (cy *cy_GB) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(cy.decimal) + len(cy.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(cy.decimal) - 1; j >= 0; j-- {
b = append(b, cy.decimal[j])
}
@@ -167,9 +163,7 @@ func (cy *cy_GB) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(cy.group) - 1; j >= 0; j-- {
b = append(b, cy.group[j])
}
@@ -183,11 +177,16 @@ func (cy *cy_GB) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(cy.minus) - 1; j >= 0; j-- {
+ b = append(b, cy.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/da/da.go b/da/da.go
index 0646122b..7a15adde 100644
--- a/da/da.go
+++ b/da/da.go
@@ -91,36 +91,24 @@ func (da *da) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (da *da) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(da.decimal) + len(da.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(da.decimal) - 1; j >= 0; j-- {
- b = append(b, da.decimal[j])
- }
-
+ b = append(b, da.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(da.group) - 1; j >= 0; j-- {
- b = append(b, da.group[j])
- }
-
+ b = append(b, da.group[0])
count = 1
} else {
count++
@@ -130,11 +118,14 @@ func (da *da) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, da.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/da_DK/da_DK.go b/da_DK/da_DK.go
index d4446c7b..eb195110 100644
--- a/da_DK/da_DK.go
+++ b/da_DK/da_DK.go
@@ -91,36 +91,24 @@ func (da *da_DK) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (da *da_DK) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(da.decimal) + len(da.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(da.decimal) - 1; j >= 0; j-- {
- b = append(b, da.decimal[j])
- }
-
+ b = append(b, da.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(da.group) - 1; j >= 0; j-- {
- b = append(b, da.group[j])
- }
-
+ b = append(b, da.group[0])
count = 1
} else {
count++
@@ -130,11 +118,14 @@ func (da *da_DK) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, da.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/da_GL/da_GL.go b/da_GL/da_GL.go
index 99ea1cac..1022cd5f 100644
--- a/da_GL/da_GL.go
+++ b/da_GL/da_GL.go
@@ -91,36 +91,24 @@ func (da *da_GL) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (da *da_GL) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(da.decimal) + len(da.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(da.decimal) - 1; j >= 0; j-- {
- b = append(b, da.decimal[j])
- }
-
+ b = append(b, da.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(da.group) - 1; j >= 0; j-- {
- b = append(b, da.group[j])
- }
-
+ b = append(b, da.group[0])
count = 1
} else {
count++
@@ -130,11 +118,14 @@ func (da *da_GL) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, da.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/dav/dav.go b/dav/dav.go
index b6ffcbac..df08819d 100644
--- a/dav/dav.go
+++ b/dav/dav.go
@@ -1,6 +1,7 @@
package dav
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,8 +69,6 @@ func (dav *dav) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (dav *dav) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/dav_KE/dav_KE.go b/dav_KE/dav_KE.go
index 5cce9bd3..1ae3e8cd 100644
--- a/dav_KE/dav_KE.go
+++ b/dav_KE/dav_KE.go
@@ -1,6 +1,7 @@
package dav_KE
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,8 +69,6 @@ func (dav *dav_KE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (dav *dav_KE) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/de/de.go b/de/de.go
index 06b62819..f245aa02 100644
--- a/de/de.go
+++ b/de/de.go
@@ -88,36 +88,24 @@ func (de *de) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (de *de) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(de.decimal) + len(de.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(de.decimal) - 1; j >= 0; j-- {
- b = append(b, de.decimal[j])
- }
-
+ b = append(b, de.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(de.group) - 1; j >= 0; j-- {
- b = append(b, de.group[j])
- }
-
+ b = append(b, de.group[0])
count = 1
} else {
count++
@@ -127,11 +115,14 @@ func (de *de) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, de.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/de_AT/de_AT.go b/de_AT/de_AT.go
index 81d73f01..da824a98 100644
--- a/de_AT/de_AT.go
+++ b/de_AT/de_AT.go
@@ -88,32 +88,23 @@ func (de *de_AT) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (de *de_AT) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(de.decimal) + len(de.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(de.decimal) - 1; j >= 0; j-- {
- b = append(b, de.decimal[j])
- }
-
+ b = append(b, de.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(de.group) - 1; j >= 0; j-- {
b = append(b, de.group[j])
}
@@ -127,11 +118,14 @@ func (de *de_AT) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, de.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/de_BE/de_BE.go b/de_BE/de_BE.go
index 51aa9abd..e42e806b 100644
--- a/de_BE/de_BE.go
+++ b/de_BE/de_BE.go
@@ -88,36 +88,24 @@ func (de *de_BE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (de *de_BE) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(de.decimal) + len(de.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(de.decimal) - 1; j >= 0; j-- {
- b = append(b, de.decimal[j])
- }
-
+ b = append(b, de.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(de.group) - 1; j >= 0; j-- {
- b = append(b, de.group[j])
- }
-
+ b = append(b, de.group[0])
count = 1
} else {
count++
@@ -127,11 +115,14 @@ func (de *de_BE) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, de.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/de_CH/de_CH.go b/de_CH/de_CH.go
index 264909f3..733feb76 100644
--- a/de_CH/de_CH.go
+++ b/de_CH/de_CH.go
@@ -88,36 +88,24 @@ func (de *de_CH) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (de *de_CH) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(de.decimal) + len(de.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(de.decimal) - 1; j >= 0; j-- {
- b = append(b, de.decimal[j])
- }
-
+ b = append(b, de.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(de.group) - 1; j >= 0; j-- {
- b = append(b, de.group[j])
- }
-
+ b = append(b, de.group[0])
count = 1
} else {
count++
@@ -127,11 +115,14 @@ func (de *de_CH) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, de.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/de_DE/de_DE.go b/de_DE/de_DE.go
index d24b34e2..bea45d8d 100644
--- a/de_DE/de_DE.go
+++ b/de_DE/de_DE.go
@@ -88,36 +88,24 @@ func (de *de_DE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (de *de_DE) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(de.decimal) + len(de.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(de.decimal) - 1; j >= 0; j-- {
- b = append(b, de.decimal[j])
- }
-
+ b = append(b, de.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(de.group) - 1; j >= 0; j-- {
- b = append(b, de.group[j])
- }
-
+ b = append(b, de.group[0])
count = 1
} else {
count++
@@ -127,11 +115,14 @@ func (de *de_DE) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, de.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/de_LI/de_LI.go b/de_LI/de_LI.go
index e9d1ef03..05e3af29 100644
--- a/de_LI/de_LI.go
+++ b/de_LI/de_LI.go
@@ -88,36 +88,24 @@ func (de *de_LI) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (de *de_LI) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(de.decimal) + len(de.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(de.decimal) - 1; j >= 0; j-- {
- b = append(b, de.decimal[j])
- }
-
+ b = append(b, de.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(de.group) - 1; j >= 0; j-- {
- b = append(b, de.group[j])
- }
-
+ b = append(b, de.group[0])
count = 1
} else {
count++
@@ -127,11 +115,14 @@ func (de *de_LI) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, de.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/de_LU/de_LU.go b/de_LU/de_LU.go
index a0196726..e6427d87 100644
--- a/de_LU/de_LU.go
+++ b/de_LU/de_LU.go
@@ -88,36 +88,24 @@ func (de *de_LU) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (de *de_LU) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(de.decimal) + len(de.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(de.decimal) - 1; j >= 0; j-- {
- b = append(b, de.decimal[j])
- }
-
+ b = append(b, de.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(de.group) - 1; j >= 0; j-- {
- b = append(b, de.group[j])
- }
-
+ b = append(b, de.group[0])
count = 1
} else {
count++
@@ -127,11 +115,14 @@ func (de *de_LU) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, de.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/dje/dje.go b/dje/dje.go
index 7c275f05..fbc7e5cd 100644
--- a/dje/dje.go
+++ b/dje/dje.go
@@ -1,6 +1,7 @@
package dje
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,32 +69,23 @@ func (dje *dje) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (dje *dje) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(dje.decimal) + len(dje.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(dje.decimal) - 1; j >= 0; j-- {
- b = append(b, dje.decimal[j])
- }
-
+ b = append(b, dje.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(dje.group) - 1; j >= 0; j-- {
b = append(b, dje.group[j])
}
@@ -107,11 +99,16 @@ func (dje *dje) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(dje.minus) - 1; j >= 0; j-- {
+ b = append(b, dje.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/dje_NE/dje_NE.go b/dje_NE/dje_NE.go
index e8b20f6f..585079dc 100644
--- a/dje_NE/dje_NE.go
+++ b/dje_NE/dje_NE.go
@@ -1,6 +1,7 @@
package dje_NE
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,32 +69,23 @@ func (dje *dje_NE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (dje *dje_NE) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(dje.decimal) + len(dje.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(dje.decimal) - 1; j >= 0; j-- {
- b = append(b, dje.decimal[j])
- }
-
+ b = append(b, dje.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(dje.group) - 1; j >= 0; j-- {
b = append(b, dje.group[j])
}
@@ -107,11 +99,16 @@ func (dje *dje_NE) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(dje.minus) - 1; j >= 0; j-- {
+ b = append(b, dje.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/dsb/dsb.go b/dsb/dsb.go
index 22f4df45..f1034331 100644
--- a/dsb/dsb.go
+++ b/dsb/dsb.go
@@ -84,36 +84,24 @@ func (dsb *dsb) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (dsb *dsb) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(dsb.decimal) + len(dsb.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(dsb.decimal) - 1; j >= 0; j-- {
- b = append(b, dsb.decimal[j])
- }
-
+ b = append(b, dsb.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(dsb.group) - 1; j >= 0; j-- {
- b = append(b, dsb.group[j])
- }
-
+ b = append(b, dsb.group[0])
count = 1
} else {
count++
@@ -123,11 +111,14 @@ func (dsb *dsb) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, dsb.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/dsb_DE/dsb_DE.go b/dsb_DE/dsb_DE.go
index dd759221..87eca207 100644
--- a/dsb_DE/dsb_DE.go
+++ b/dsb_DE/dsb_DE.go
@@ -84,36 +84,24 @@ func (dsb *dsb_DE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (dsb *dsb_DE) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(dsb.decimal) + len(dsb.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(dsb.decimal) - 1; j >= 0; j-- {
- b = append(b, dsb.decimal[j])
- }
-
+ b = append(b, dsb.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(dsb.group) - 1; j >= 0; j-- {
- b = append(b, dsb.group[j])
- }
-
+ b = append(b, dsb.group[0])
count = 1
} else {
count++
@@ -123,11 +111,14 @@ func (dsb *dsb_DE) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, dsb.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/dua/dua.go b/dua/dua.go
index b5f9afd1..24a41fe2 100644
--- a/dua/dua.go
+++ b/dua/dua.go
@@ -1,6 +1,7 @@
package dua
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,32 +69,23 @@ func (dua *dua) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (dua *dua) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(dua.decimal) + len(dua.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(dua.decimal) - 1; j >= 0; j-- {
- b = append(b, dua.decimal[j])
- }
-
+ b = append(b, dua.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(dua.group) - 1; j >= 0; j-- {
b = append(b, dua.group[j])
}
@@ -107,11 +99,16 @@ func (dua *dua) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(dua.minus) - 1; j >= 0; j-- {
+ b = append(b, dua.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/dua_CM/dua_CM.go b/dua_CM/dua_CM.go
index 5ec10f7d..1e76ec8a 100644
--- a/dua_CM/dua_CM.go
+++ b/dua_CM/dua_CM.go
@@ -1,6 +1,7 @@
package dua_CM
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,32 +69,23 @@ func (dua *dua_CM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (dua *dua_CM) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(dua.decimal) + len(dua.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(dua.decimal) - 1; j >= 0; j-- {
- b = append(b, dua.decimal[j])
- }
-
+ b = append(b, dua.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(dua.group) - 1; j >= 0; j-- {
b = append(b, dua.group[j])
}
@@ -107,11 +99,16 @@ func (dua *dua_CM) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(dua.minus) - 1; j >= 0; j-- {
+ b = append(b, dua.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/dyo/dyo.go b/dyo/dyo.go
index 2afdc998..fb893f17 100644
--- a/dyo/dyo.go
+++ b/dyo/dyo.go
@@ -1,6 +1,7 @@
package dyo
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,32 +69,23 @@ func (dyo *dyo) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (dyo *dyo) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(dyo.decimal) + len(dyo.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(dyo.decimal) - 1; j >= 0; j-- {
- b = append(b, dyo.decimal[j])
- }
-
+ b = append(b, dyo.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(dyo.group) - 1; j >= 0; j-- {
b = append(b, dyo.group[j])
}
@@ -107,11 +99,16 @@ func (dyo *dyo) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(dyo.minus) - 1; j >= 0; j-- {
+ b = append(b, dyo.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/dyo_SN/dyo_SN.go b/dyo_SN/dyo_SN.go
index c281ac46..c02759b2 100644
--- a/dyo_SN/dyo_SN.go
+++ b/dyo_SN/dyo_SN.go
@@ -1,6 +1,7 @@
package dyo_SN
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,32 +69,23 @@ func (dyo *dyo_SN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (dyo *dyo_SN) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(dyo.decimal) + len(dyo.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(dyo.decimal) - 1; j >= 0; j-- {
- b = append(b, dyo.decimal[j])
- }
-
+ b = append(b, dyo.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(dyo.group) - 1; j >= 0; j-- {
b = append(b, dyo.group[j])
}
@@ -107,11 +99,16 @@ func (dyo *dyo_SN) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(dyo.minus) - 1; j >= 0; j-- {
+ b = append(b, dyo.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/dz/dz.go b/dz/dz.go
index 8829bbfa..6d1289f9 100644
--- a/dz/dz.go
+++ b/dz/dz.go
@@ -1,6 +1,7 @@
package dz
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,23 +69,19 @@ func (dz *dz) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (dz *dz) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(dz.decimal) + len(dz.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
+ inSecondary := false
+ groupThreshold := 3
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(dz.decimal) - 1; j >= 0; j-- {
- b = append(b, dz.decimal[j])
- }
-
+ b = append(b, dz.decimal[0])
inWhole = true
continue
@@ -92,13 +89,14 @@ func (dz *dz) FmtNumber(num float64, v uint64) []byte {
if inWhole {
- if count == 3 {
+ if count == groupThreshold {
+ b = append(b, dz.group[0])
+ count = 1
- for j := len(dz.group) - 1; j >= 0; j-- {
- b = append(b, dz.group[j])
+ if !inSecondary {
+ inSecondary = true
+ groupThreshold = 2
}
-
- count = 1
} else {
count++
}
@@ -107,11 +105,14 @@ func (dz *dz) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, dz.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/dz_BT/dz_BT.go b/dz_BT/dz_BT.go
index 78493378..05016eee 100644
--- a/dz_BT/dz_BT.go
+++ b/dz_BT/dz_BT.go
@@ -1,6 +1,7 @@
package dz_BT
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,23 +69,19 @@ func (dz *dz_BT) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (dz *dz_BT) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(dz.decimal) + len(dz.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
+ inSecondary := false
+ groupThreshold := 3
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(dz.decimal) - 1; j >= 0; j-- {
- b = append(b, dz.decimal[j])
- }
-
+ b = append(b, dz.decimal[0])
inWhole = true
continue
@@ -92,13 +89,14 @@ func (dz *dz_BT) FmtNumber(num float64, v uint64) []byte {
if inWhole {
- if count == 3 {
+ if count == groupThreshold {
+ b = append(b, dz.group[0])
+ count = 1
- for j := len(dz.group) - 1; j >= 0; j-- {
- b = append(b, dz.group[j])
+ if !inSecondary {
+ inSecondary = true
+ groupThreshold = 2
}
-
- count = 1
} else {
count++
}
@@ -107,11 +105,14 @@ func (dz *dz_BT) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, dz.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ebu/ebu.go b/ebu/ebu.go
index b8b58bcf..84e9f04b 100644
--- a/ebu/ebu.go
+++ b/ebu/ebu.go
@@ -1,6 +1,7 @@
package ebu
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,8 +69,6 @@ func (ebu *ebu) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (ebu *ebu) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/ebu_KE/ebu_KE.go b/ebu_KE/ebu_KE.go
index 4065cd2f..4ca08f23 100644
--- a/ebu_KE/ebu_KE.go
+++ b/ebu_KE/ebu_KE.go
@@ -1,6 +1,7 @@
package ebu_KE
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,8 +69,6 @@ func (ebu *ebu_KE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (ebu *ebu_KE) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/ee/ee.go b/ee/ee.go
index 0f03183b..ac5f248c 100644
--- a/ee/ee.go
+++ b/ee/ee.go
@@ -76,8 +76,6 @@ func (ee *ee) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (ee *ee) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/ee_GH/ee_GH.go b/ee_GH/ee_GH.go
index e56f73e1..09e58e5f 100644
--- a/ee_GH/ee_GH.go
+++ b/ee_GH/ee_GH.go
@@ -76,8 +76,6 @@ func (ee *ee_GH) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ee *ee_GH) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/ee_TG/ee_TG.go b/ee_TG/ee_TG.go
index c97bcbc8..637f1152 100644
--- a/ee_TG/ee_TG.go
+++ b/ee_TG/ee_TG.go
@@ -76,8 +76,6 @@ func (ee *ee_TG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ee *ee_TG) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/el/el.go b/el/el.go
index 27558538..87dee2c4 100644
--- a/el/el.go
+++ b/el/el.go
@@ -87,36 +87,24 @@ func (el *el) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (el *el) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(el.decimal) + len(el.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(el.decimal) - 1; j >= 0; j-- {
- b = append(b, el.decimal[j])
- }
-
+ b = append(b, el.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(el.group) - 1; j >= 0; j-- {
- b = append(b, el.group[j])
- }
-
+ b = append(b, el.group[0])
count = 1
} else {
count++
@@ -126,11 +114,14 @@ func (el *el) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, el.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/el_CY/el_CY.go b/el_CY/el_CY.go
index d5ac60f7..87420582 100644
--- a/el_CY/el_CY.go
+++ b/el_CY/el_CY.go
@@ -87,36 +87,24 @@ func (el *el_CY) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (el *el_CY) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(el.decimal) + len(el.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(el.decimal) - 1; j >= 0; j-- {
- b = append(b, el.decimal[j])
- }
-
+ b = append(b, el.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(el.group) - 1; j >= 0; j-- {
- b = append(b, el.group[j])
- }
-
+ b = append(b, el.group[0])
count = 1
} else {
count++
@@ -126,11 +114,14 @@ func (el *el_CY) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, el.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/el_GR/el_GR.go b/el_GR/el_GR.go
index 2212e3f5..8bd8d46e 100644
--- a/el_GR/el_GR.go
+++ b/el_GR/el_GR.go
@@ -87,36 +87,24 @@ func (el *el_GR) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (el *el_GR) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(el.decimal) + len(el.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(el.decimal) - 1; j >= 0; j-- {
- b = append(b, el.decimal[j])
- }
-
+ b = append(b, el.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(el.group) - 1; j >= 0; j-- {
- b = append(b, el.group[j])
- }
-
+ b = append(b, el.group[0])
count = 1
} else {
count++
@@ -126,11 +114,14 @@ func (el *el_GR) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, el.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en/en.go b/en/en.go
index a0d0d15d..52a838ba 100644
--- a/en/en.go
+++ b/en/en.go
@@ -30,7 +30,7 @@ func New() locales.Translator {
minus: []byte{0x2d},
percent: []byte{0x25},
perMille: []byte{0xe2, 0x80, 0xb0},
- currencies: [][]uint8{{0x41, 0x44, 0x50}, {0x41, 0x45, 0x44}, {0x41, 0x46, 0x41}, {0x41, 0x46, 0x4e}, {0x41, 0x4c, 0x4b}, {0x41, 0x4c, 0x4c}, {0x41, 0x4d, 0x44}, {0x41, 0x4e, 0x47}, {0x41, 0x4f, 0x41}, {0x41, 0x4f, 0x4b}, {0x41, 0x4f, 0x4e}, {0x41, 0x4f, 0x52}, {0x41, 0x52, 0x41}, {0x41, 0x52, 0x4c}, {0x41, 0x52, 0x4d}, {0x41, 0x52, 0x50}, {0x41, 0x52, 0x53}, {0x41, 0x54, 0x53}, {0x41, 0x55, 0x44}, {0x41, 0x57, 0x47}, {0x41, 0x5a, 0x4d}, {0x41, 0x5a, 0x4e}, {0x42, 0x41, 0x44}, {0x42, 0x41, 0x4d}, {0x42, 0x41, 0x4e}, {0x42, 0x42, 0x44}, {0x42, 0x44, 0x54}, {0x42, 0x45, 0x43}, {0x42, 0x45, 0x46}, {0x42, 0x45, 0x4c}, {0x42, 0x47, 0x4c}, {0x42, 0x47, 0x4d}, {0x42, 0x47, 0x4e}, {0x42, 0x47, 0x4f}, {0x42, 0x48, 0x44}, {0x42, 0x49, 0x46}, {0x42, 0x4d, 0x44}, {0x42, 0x4e, 0x44}, {0x42, 0x4f, 0x42}, {0x42, 0x4f, 0x4c}, {0x42, 0x4f, 0x50}, {0x42, 0x4f, 0x56}, {0x42, 0x52, 0x42}, {0x42, 0x52, 0x43}, {0x42, 0x52, 0x45}, {0x42, 0x52, 0x4c}, {0x42, 0x52, 0x4e}, {0x42, 0x52, 0x52}, {0x42, 0x52, 0x5a}, {0x42, 0x53, 0x44}, {0x42, 0x54, 0x4e}, {0x42, 0x55, 0x4b}, {0x42, 0x57, 0x50}, {0x42, 0x59, 0x42}, {0x42, 0x59, 0x52}, {0x42, 0x5a, 0x44}, {0x43, 0x41, 0x44}, {0x43, 0x44, 0x46}, {0x43, 0x48, 0x45}, {0x43, 0x48, 0x46}, {0x43, 0x48, 0x57}, {0x43, 0x4c, 0x45}, {0x43, 0x4c, 0x46}, {0x43, 0x4c, 0x50}, {0x43, 0x4e, 0x58}, {0x43, 0x4e, 0x59}, {0x43, 0x4f, 0x50}, {0x43, 0x4f, 0x55}, {0x43, 0x52, 0x43}, {0x43, 0x53, 0x44}, {0x43, 0x53, 0x4b}, {0x43, 0x55, 0x43}, {0x43, 0x55, 0x50}, {0x43, 0x56, 0x45}, {0x43, 0x59, 0x50}, {0x43, 0x5a, 0x4b}, {0x44, 0x44, 0x4d}, {0x44, 0x45, 0x4d}, {0x44, 0x4a, 0x46}, {0x44, 0x4b, 0x4b}, {0x44, 0x4f, 0x50}, {0x44, 0x5a, 0x44}, {0x45, 0x43, 0x53}, {0x45, 0x43, 0x56}, {0x45, 0x45, 0x4b}, {0x45, 0x47, 0x50}, {0x45, 0x52, 0x4e}, {0x45, 0x53, 0x41}, {0x45, 0x53, 0x42}, {0x45, 0x53, 0x50}, {0x45, 0x54, 0x42}, {0x45, 0x55, 0x52}, {0x46, 0x49, 0x4d}, {0x46, 0x4a, 0x44}, {0x46, 0x4b, 0x50}, {0x46, 0x52, 0x46}, {0x47, 0x42, 0x50}, {0x47, 0x45, 0x4b}, {0x47, 0x45, 0x4c}, {0x47, 0x48, 0x43}, {0x47, 0x48, 0x53}, {0x47, 0x49, 0x50}, {0x47, 0x4d, 0x44}, {0x47, 0x4e, 0x46}, {0x47, 0x4e, 0x53}, {0x47, 0x51, 0x45}, {0x47, 0x52, 0x44}, {0x47, 0x54, 0x51}, {0x47, 0x57, 0x45}, {0x47, 0x57, 0x50}, {0x47, 0x59, 0x44}, {0x48, 0x4b, 0x44}, {0x48, 0x4e, 0x4c}, {0x48, 0x52, 0x44}, {0x48, 0x52, 0x4b}, {0x48, 0x54, 0x47}, {0x48, 0x55, 0x46}, {0x49, 0x44, 0x52}, {0x49, 0x45, 0x50}, {0x49, 0x4c, 0x50}, {0x49, 0x4c, 0x52}, {0x49, 0x4c, 0x53}, {0x49, 0x4e, 0x52}, {0x49, 0x51, 0x44}, {0x49, 0x52, 0x52}, {0x49, 0x53, 0x4a}, {0x49, 0x53, 0x4b}, {0x49, 0x54, 0x4c}, {0x4a, 0x4d, 0x44}, {0x4a, 0x4f, 0x44}, {0xc2, 0xa5}, {0x4b, 0x45, 0x53}, {0x4b, 0x47, 0x53}, {0x4b, 0x48, 0x52}, {0x4b, 0x4d, 0x46}, {0x4b, 0x50, 0x57}, {0x4b, 0x52, 0x48}, {0x4b, 0x52, 0x4f}, {0x4b, 0x52, 0x57}, {0x4b, 0x57, 0x44}, {0x4b, 0x59, 0x44}, {0x4b, 0x5a, 0x54}, {0x4c, 0x41, 0x4b}, {0x4c, 0x42, 0x50}, {0x4c, 0x4b, 0x52}, {0x4c, 0x52, 0x44}, {0x4c, 0x53, 0x4c}, {0x4c, 0x54, 0x4c}, {0x4c, 0x54, 0x54}, {0x4c, 0x55, 0x43}, {0x4c, 0x55, 0x46}, {0x4c, 0x55, 0x4c}, {0x4c, 0x56, 0x4c}, {0x4c, 0x56, 0x52}, {0x4c, 0x59, 0x44}, {0x4d, 0x41, 0x44}, {0x4d, 0x41, 0x46}, {0x4d, 0x43, 0x46}, {0x4d, 0x44, 0x43}, {0x4d, 0x44, 0x4c}, {0x4d, 0x47, 0x41}, {0x4d, 0x47, 0x46}, {0x4d, 0x4b, 0x44}, {0x4d, 0x4b, 0x4e}, {0x4d, 0x4c, 0x46}, {0x4d, 0x4d, 0x4b}, {0x4d, 0x4e, 0x54}, {0x4d, 0x4f, 0x50}, {0x4d, 0x52, 0x4f}, {0x4d, 0x54, 0x4c}, {0x4d, 0x54, 0x50}, {0x4d, 0x55, 0x52}, {0x4d, 0x56, 0x50}, {0x4d, 0x56, 0x52}, {0x4d, 0x57, 0x4b}, {0x4d, 0x58, 0x4e}, {0x4d, 0x58, 0x50}, {0x4d, 0x58, 0x56}, {0x4d, 0x59, 0x52}, {0x4d, 0x5a, 0x45}, {0x4d, 0x5a, 0x4d}, {0x4d, 0x5a, 0x4e}, {0x4e, 0x41, 0x44}, {0x4e, 0x47, 0x4e}, {0x4e, 0x49, 0x43}, {0x4e, 0x49, 0x4f}, {0x4e, 0x4c, 0x47}, {0x4e, 0x4f, 0x4b}, {0x4e, 0x50, 0x52}, {0x4e, 0x5a, 0x44}, {0x4f, 0x4d, 0x52}, {0x50, 0x41, 0x42}, {0x50, 0x45, 0x49}, {0x50, 0x45, 0x4e}, {0x50, 0x45, 0x53}, {0x50, 0x47, 0x4b}, {0x50, 0x48, 0x50}, {0x50, 0x4b, 0x52}, {0x50, 0x4c, 0x4e}, {0x50, 0x4c, 0x5a}, {0x50, 0x54, 0x45}, {0x50, 0x59, 0x47}, {0x51, 0x41, 0x52}, {0x52, 0x48, 0x44}, {0x52, 0x4f, 0x4c}, {0x52, 0x4f, 0x4e}, {0x52, 0x53, 0x44}, {0x52, 0x55, 0x42}, {0x52, 0x55, 0x52}, {0x52, 0x57, 0x46}, {0x53, 0x41, 0x52}, {0x53, 0x42, 0x44}, {0x53, 0x43, 0x52}, {0x53, 0x44, 0x44}, {0x53, 0x44, 0x47}, {0x53, 0x44, 0x50}, {0x53, 0x45, 0x4b}, {0x53, 0x47, 0x44}, {0x53, 0x48, 0x50}, {0x53, 0x49, 0x54}, {0x53, 0x4b, 0x4b}, {0x53, 0x4c, 0x4c}, {0x53, 0x4f, 0x53}, {0x53, 0x52, 0x44}, {0x53, 0x52, 0x47}, {0x53, 0x53, 0x50}, {0x53, 0x54, 0x44}, {0x53, 0x55, 0x52}, {0x53, 0x56, 0x43}, {0x53, 0x59, 0x50}, {0x53, 0x5a, 0x4c}, {0x54, 0x48, 0x42}, {0x54, 0x4a, 0x52}, {0x54, 0x4a, 0x53}, {0x54, 0x4d, 0x4d}, {0x54, 0x4d, 0x54}, {0x54, 0x4e, 0x44}, {0x54, 0x4f, 0x50}, {0x54, 0x50, 0x45}, {0x54, 0x52, 0x4c}, {0x54, 0x52, 0x59}, {0x54, 0x54, 0x44}, {0x54, 0x57, 0x44}, {0x54, 0x5a, 0x53}, {0x55, 0x41, 0x48}, {0x55, 0x41, 0x4b}, {0x55, 0x47, 0x53}, {0x55, 0x47, 0x58}, {0x24}, {0x55, 0x53, 0x4e}, {0x55, 0x53, 0x53}, {0x55, 0x59, 0x49}, {0x55, 0x59, 0x50}, {0x55, 0x59, 0x55}, {0x55, 0x5a, 0x53}, {0x56, 0x45, 0x42}, {0x56, 0x45, 0x46}, {0x56, 0x4e, 0x44}, {0x56, 0x4e, 0x4e}, {0x56, 0x55, 0x56}, {0x57, 0x53, 0x54}, {0x58, 0x41, 0x46}, {0x58, 0x41, 0x47}, {0x58, 0x41, 0x55}, {0x58, 0x42, 0x41}, {0x58, 0x42, 0x42}, {0x58, 0x42, 0x43}, {0x58, 0x42, 0x44}, {0x58, 0x43, 0x44}, {0x58, 0x44, 0x52}, {0x58, 0x45, 0x55}, {0x58, 0x46, 0x4f}, {0x58, 0x46, 0x55}, {0x58, 0x4f, 0x46}, {0x58, 0x50, 0x44}, {0x58, 0x50, 0x46}, {0x58, 0x50, 0x54}, {0x58, 0x52, 0x45}, {0x58, 0x53, 0x55}, {0x58, 0x54, 0x53}, {0x58, 0x55, 0x41}, {0x58, 0x58, 0x58}, {0x59, 0x44, 0x44}, {0x59, 0x45, 0x52}, {0x59, 0x55, 0x44}, {0x59, 0x55, 0x4d}, {0x59, 0x55, 0x4e}, {0x59, 0x55, 0x52}, {0x5a, 0x41, 0x4c}, {0x5a, 0x41, 0x52}, {0x5a, 0x4d, 0x4b}, {0x5a, 0x4d, 0x57}, {0x5a, 0x52, 0x4e}, {0x5a, 0x52, 0x5a}, {0x5a, 0x57, 0x44}, {0x5a, 0x57, 0x4c}, {0x5a, 0x57, 0x52}},
+ currencies: [][]uint8{[]uint8{0x41, 0x44, 0x50}, []uint8{0x41, 0x45, 0x44}, []uint8{0x41, 0x46, 0x41}, []uint8{0x41, 0x46, 0x4e}, []uint8{0x41, 0x4c, 0x4b}, []uint8{0x41, 0x4c, 0x4c}, []uint8{0x41, 0x4d, 0x44}, []uint8{0x41, 0x4e, 0x47}, []uint8{0x41, 0x4f, 0x41}, []uint8{0x41, 0x4f, 0x4b}, []uint8{0x41, 0x4f, 0x4e}, []uint8{0x41, 0x4f, 0x52}, []uint8{0x41, 0x52, 0x41}, []uint8{0x41, 0x52, 0x4c}, []uint8{0x41, 0x52, 0x4d}, []uint8{0x41, 0x52, 0x50}, []uint8{0x41, 0x52, 0x53}, []uint8{0x41, 0x54, 0x53}, []uint8{0x41, 0x55, 0x44}, []uint8{0x41, 0x57, 0x47}, []uint8{0x41, 0x5a, 0x4d}, []uint8{0x41, 0x5a, 0x4e}, []uint8{0x42, 0x41, 0x44}, []uint8{0x42, 0x41, 0x4d}, []uint8{0x42, 0x41, 0x4e}, []uint8{0x42, 0x42, 0x44}, []uint8{0x42, 0x44, 0x54}, []uint8{0x42, 0x45, 0x43}, []uint8{0x42, 0x45, 0x46}, []uint8{0x42, 0x45, 0x4c}, []uint8{0x42, 0x47, 0x4c}, []uint8{0x42, 0x47, 0x4d}, []uint8{0x42, 0x47, 0x4e}, []uint8{0x42, 0x47, 0x4f}, []uint8{0x42, 0x48, 0x44}, []uint8{0x42, 0x49, 0x46}, []uint8{0x42, 0x4d, 0x44}, []uint8{0x42, 0x4e, 0x44}, []uint8{0x42, 0x4f, 0x42}, []uint8{0x42, 0x4f, 0x4c}, []uint8{0x42, 0x4f, 0x50}, []uint8{0x42, 0x4f, 0x56}, []uint8{0x42, 0x52, 0x42}, []uint8{0x42, 0x52, 0x43}, []uint8{0x42, 0x52, 0x45}, []uint8{0x42, 0x52, 0x4c}, []uint8{0x42, 0x52, 0x4e}, []uint8{0x42, 0x52, 0x52}, []uint8{0x42, 0x52, 0x5a}, []uint8{0x42, 0x53, 0x44}, []uint8{0x42, 0x54, 0x4e}, []uint8{0x42, 0x55, 0x4b}, []uint8{0x42, 0x57, 0x50}, []uint8{0x42, 0x59, 0x42}, []uint8{0x42, 0x59, 0x52}, []uint8{0x42, 0x5a, 0x44}, []uint8{0x43, 0x41, 0x44}, []uint8{0x43, 0x44, 0x46}, []uint8{0x43, 0x48, 0x45}, []uint8{0x43, 0x48, 0x46}, []uint8{0x43, 0x48, 0x57}, []uint8{0x43, 0x4c, 0x45}, []uint8{0x43, 0x4c, 0x46}, []uint8{0x43, 0x4c, 0x50}, []uint8{0x43, 0x4e, 0x58}, []uint8{0x43, 0x4e, 0x59}, []uint8{0x43, 0x4f, 0x50}, []uint8{0x43, 0x4f, 0x55}, []uint8{0x43, 0x52, 0x43}, []uint8{0x43, 0x53, 0x44}, []uint8{0x43, 0x53, 0x4b}, []uint8{0x43, 0x55, 0x43}, []uint8{0x43, 0x55, 0x50}, []uint8{0x43, 0x56, 0x45}, []uint8{0x43, 0x59, 0x50}, []uint8{0x43, 0x5a, 0x4b}, []uint8{0x44, 0x44, 0x4d}, []uint8{0x44, 0x45, 0x4d}, []uint8{0x44, 0x4a, 0x46}, []uint8{0x44, 0x4b, 0x4b}, []uint8{0x44, 0x4f, 0x50}, []uint8{0x44, 0x5a, 0x44}, []uint8{0x45, 0x43, 0x53}, []uint8{0x45, 0x43, 0x56}, []uint8{0x45, 0x45, 0x4b}, []uint8{0x45, 0x47, 0x50}, []uint8{0x45, 0x52, 0x4e}, []uint8{0x45, 0x53, 0x41}, []uint8{0x45, 0x53, 0x42}, []uint8{0x45, 0x53, 0x50}, []uint8{0x45, 0x54, 0x42}, []uint8{0x45, 0x55, 0x52}, []uint8{0x46, 0x49, 0x4d}, []uint8{0x46, 0x4a, 0x44}, []uint8{0x46, 0x4b, 0x50}, []uint8{0x46, 0x52, 0x46}, []uint8{0x47, 0x42, 0x50}, []uint8{0x47, 0x45, 0x4b}, []uint8{0x47, 0x45, 0x4c}, []uint8{0x47, 0x48, 0x43}, []uint8{0x47, 0x48, 0x53}, []uint8{0x47, 0x49, 0x50}, []uint8{0x47, 0x4d, 0x44}, []uint8{0x47, 0x4e, 0x46}, []uint8{0x47, 0x4e, 0x53}, []uint8{0x47, 0x51, 0x45}, []uint8{0x47, 0x52, 0x44}, []uint8{0x47, 0x54, 0x51}, []uint8{0x47, 0x57, 0x45}, []uint8{0x47, 0x57, 0x50}, []uint8{0x47, 0x59, 0x44}, []uint8{0x48, 0x4b, 0x44}, []uint8{0x48, 0x4e, 0x4c}, []uint8{0x48, 0x52, 0x44}, []uint8{0x48, 0x52, 0x4b}, []uint8{0x48, 0x54, 0x47}, []uint8{0x48, 0x55, 0x46}, []uint8{0x49, 0x44, 0x52}, []uint8{0x49, 0x45, 0x50}, []uint8{0x49, 0x4c, 0x50}, []uint8{0x49, 0x4c, 0x52}, []uint8{0x49, 0x4c, 0x53}, []uint8{0x49, 0x4e, 0x52}, []uint8{0x49, 0x51, 0x44}, []uint8{0x49, 0x52, 0x52}, []uint8{0x49, 0x53, 0x4a}, []uint8{0x49, 0x53, 0x4b}, []uint8{0x49, 0x54, 0x4c}, []uint8{0x4a, 0x4d, 0x44}, []uint8{0x4a, 0x4f, 0x44}, []uint8{0xc2, 0xa5}, []uint8{0x4b, 0x45, 0x53}, []uint8{0x4b, 0x47, 0x53}, []uint8{0x4b, 0x48, 0x52}, []uint8{0x4b, 0x4d, 0x46}, []uint8{0x4b, 0x50, 0x57}, []uint8{0x4b, 0x52, 0x48}, []uint8{0x4b, 0x52, 0x4f}, []uint8{0x4b, 0x52, 0x57}, []uint8{0x4b, 0x57, 0x44}, []uint8{0x4b, 0x59, 0x44}, []uint8{0x4b, 0x5a, 0x54}, []uint8{0x4c, 0x41, 0x4b}, []uint8{0x4c, 0x42, 0x50}, []uint8{0x4c, 0x4b, 0x52}, []uint8{0x4c, 0x52, 0x44}, []uint8{0x4c, 0x53, 0x4c}, []uint8{0x4c, 0x54, 0x4c}, []uint8{0x4c, 0x54, 0x54}, []uint8{0x4c, 0x55, 0x43}, []uint8{0x4c, 0x55, 0x46}, []uint8{0x4c, 0x55, 0x4c}, []uint8{0x4c, 0x56, 0x4c}, []uint8{0x4c, 0x56, 0x52}, []uint8{0x4c, 0x59, 0x44}, []uint8{0x4d, 0x41, 0x44}, []uint8{0x4d, 0x41, 0x46}, []uint8{0x4d, 0x43, 0x46}, []uint8{0x4d, 0x44, 0x43}, []uint8{0x4d, 0x44, 0x4c}, []uint8{0x4d, 0x47, 0x41}, []uint8{0x4d, 0x47, 0x46}, []uint8{0x4d, 0x4b, 0x44}, []uint8{0x4d, 0x4b, 0x4e}, []uint8{0x4d, 0x4c, 0x46}, []uint8{0x4d, 0x4d, 0x4b}, []uint8{0x4d, 0x4e, 0x54}, []uint8{0x4d, 0x4f, 0x50}, []uint8{0x4d, 0x52, 0x4f}, []uint8{0x4d, 0x54, 0x4c}, []uint8{0x4d, 0x54, 0x50}, []uint8{0x4d, 0x55, 0x52}, []uint8{0x4d, 0x56, 0x50}, []uint8{0x4d, 0x56, 0x52}, []uint8{0x4d, 0x57, 0x4b}, []uint8{0x4d, 0x58, 0x4e}, []uint8{0x4d, 0x58, 0x50}, []uint8{0x4d, 0x58, 0x56}, []uint8{0x4d, 0x59, 0x52}, []uint8{0x4d, 0x5a, 0x45}, []uint8{0x4d, 0x5a, 0x4d}, []uint8{0x4d, 0x5a, 0x4e}, []uint8{0x4e, 0x41, 0x44}, []uint8{0x4e, 0x47, 0x4e}, []uint8{0x4e, 0x49, 0x43}, []uint8{0x4e, 0x49, 0x4f}, []uint8{0x4e, 0x4c, 0x47}, []uint8{0x4e, 0x4f, 0x4b}, []uint8{0x4e, 0x50, 0x52}, []uint8{0x4e, 0x5a, 0x44}, []uint8{0x4f, 0x4d, 0x52}, []uint8{0x50, 0x41, 0x42}, []uint8{0x50, 0x45, 0x49}, []uint8{0x50, 0x45, 0x4e}, []uint8{0x50, 0x45, 0x53}, []uint8{0x50, 0x47, 0x4b}, []uint8{0x50, 0x48, 0x50}, []uint8{0x50, 0x4b, 0x52}, []uint8{0x50, 0x4c, 0x4e}, []uint8{0x50, 0x4c, 0x5a}, []uint8{0x50, 0x54, 0x45}, []uint8{0x50, 0x59, 0x47}, []uint8{0x51, 0x41, 0x52}, []uint8{0x52, 0x48, 0x44}, []uint8{0x52, 0x4f, 0x4c}, []uint8{0x52, 0x4f, 0x4e}, []uint8{0x52, 0x53, 0x44}, []uint8{0x52, 0x55, 0x42}, []uint8{0x52, 0x55, 0x52}, []uint8{0x52, 0x57, 0x46}, []uint8{0x53, 0x41, 0x52}, []uint8{0x53, 0x42, 0x44}, []uint8{0x53, 0x43, 0x52}, []uint8{0x53, 0x44, 0x44}, []uint8{0x53, 0x44, 0x47}, []uint8{0x53, 0x44, 0x50}, []uint8{0x53, 0x45, 0x4b}, []uint8{0x53, 0x47, 0x44}, []uint8{0x53, 0x48, 0x50}, []uint8{0x53, 0x49, 0x54}, []uint8{0x53, 0x4b, 0x4b}, []uint8{0x53, 0x4c, 0x4c}, []uint8{0x53, 0x4f, 0x53}, []uint8{0x53, 0x52, 0x44}, []uint8{0x53, 0x52, 0x47}, []uint8{0x53, 0x53, 0x50}, []uint8{0x53, 0x54, 0x44}, []uint8{0x53, 0x55, 0x52}, []uint8{0x53, 0x56, 0x43}, []uint8{0x53, 0x59, 0x50}, []uint8{0x53, 0x5a, 0x4c}, []uint8{0x54, 0x48, 0x42}, []uint8{0x54, 0x4a, 0x52}, []uint8{0x54, 0x4a, 0x53}, []uint8{0x54, 0x4d, 0x4d}, []uint8{0x54, 0x4d, 0x54}, []uint8{0x54, 0x4e, 0x44}, []uint8{0x54, 0x4f, 0x50}, []uint8{0x54, 0x50, 0x45}, []uint8{0x54, 0x52, 0x4c}, []uint8{0x54, 0x52, 0x59}, []uint8{0x54, 0x54, 0x44}, []uint8{0x54, 0x57, 0x44}, []uint8{0x54, 0x5a, 0x53}, []uint8{0x55, 0x41, 0x48}, []uint8{0x55, 0x41, 0x4b}, []uint8{0x55, 0x47, 0x53}, []uint8{0x55, 0x47, 0x58}, []uint8{0x24}, []uint8{0x55, 0x53, 0x4e}, []uint8{0x55, 0x53, 0x53}, []uint8{0x55, 0x59, 0x49}, []uint8{0x55, 0x59, 0x50}, []uint8{0x55, 0x59, 0x55}, []uint8{0x55, 0x5a, 0x53}, []uint8{0x56, 0x45, 0x42}, []uint8{0x56, 0x45, 0x46}, []uint8{0x56, 0x4e, 0x44}, []uint8{0x56, 0x4e, 0x4e}, []uint8{0x56, 0x55, 0x56}, []uint8{0x57, 0x53, 0x54}, []uint8{0x58, 0x41, 0x46}, []uint8{0x58, 0x41, 0x47}, []uint8{0x58, 0x41, 0x55}, []uint8{0x58, 0x42, 0x41}, []uint8{0x58, 0x42, 0x42}, []uint8{0x58, 0x42, 0x43}, []uint8{0x58, 0x42, 0x44}, []uint8{0x58, 0x43, 0x44}, []uint8{0x58, 0x44, 0x52}, []uint8{0x58, 0x45, 0x55}, []uint8{0x58, 0x46, 0x4f}, []uint8{0x58, 0x46, 0x55}, []uint8{0x58, 0x4f, 0x46}, []uint8{0x58, 0x50, 0x44}, []uint8{0x58, 0x50, 0x46}, []uint8{0x58, 0x50, 0x54}, []uint8{0x58, 0x52, 0x45}, []uint8{0x58, 0x53, 0x55}, []uint8{0x58, 0x54, 0x53}, []uint8{0x58, 0x55, 0x41}, []uint8{0x58, 0x58, 0x58}, []uint8{0x59, 0x44, 0x44}, []uint8{0x59, 0x45, 0x52}, []uint8{0x59, 0x55, 0x44}, []uint8{0x59, 0x55, 0x4d}, []uint8{0x59, 0x55, 0x4e}, []uint8{0x59, 0x55, 0x52}, []uint8{0x5a, 0x41, 0x4c}, []uint8{0x5a, 0x41, 0x52}, []uint8{0x5a, 0x4d, 0x4b}, []uint8{0x5a, 0x4d, 0x57}, []uint8{0x5a, 0x52, 0x4e}, []uint8{0x5a, 0x52, 0x5a}, []uint8{0x5a, 0x57, 0x44}, []uint8{0x5a, 0x57, 0x4c}, []uint8{0x5a, 0x57, 0x52}},
}
}
@@ -90,36 +90,24 @@ func (en *en) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (en *en) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_001/en_001.go b/en_001/en_001.go
index deeebac8..0f7077fb 100644
--- a/en_001/en_001.go
+++ b/en_001/en_001.go
@@ -90,36 +90,24 @@ func (en *en_001) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint
// avoid allocations; otherwise just cast as string.
func (en *en_001) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_001) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_150/en_150.go b/en_150/en_150.go
index b74a96a2..9a9eac46 100644
--- a/en_150/en_150.go
+++ b/en_150/en_150.go
@@ -90,36 +90,24 @@ func (en *en_150) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint
// avoid allocations; otherwise just cast as string.
func (en *en_150) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_150) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_AG/en_AG.go b/en_AG/en_AG.go
index 662fef1e..ee3f5761 100644
--- a/en_AG/en_AG.go
+++ b/en_AG/en_AG.go
@@ -90,36 +90,24 @@ func (en *en_AG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_AG) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_AG) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_AI/en_AI.go b/en_AI/en_AI.go
index 3e642ebb..71e97a0e 100644
--- a/en_AI/en_AI.go
+++ b/en_AI/en_AI.go
@@ -66,8 +66,8 @@ func (en *en_AI) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
func (en *en_AI) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
n := math.Abs(num)
- nMod10 := math.Mod(n, 10)
nMod100 := math.Mod(n, 100)
+ nMod10 := math.Mod(n, 10)
if nMod10 == 1 && nMod100 != 11 {
return locales.PluralRuleOne
@@ -90,36 +90,24 @@ func (en *en_AI) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_AI) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_AI) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_AS/en_AS.go b/en_AS/en_AS.go
index 499102ac..58bbe659 100644
--- a/en_AS/en_AS.go
+++ b/en_AS/en_AS.go
@@ -66,8 +66,8 @@ func (en *en_AS) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
func (en *en_AS) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
n := math.Abs(num)
- nMod100 := math.Mod(n, 100)
nMod10 := math.Mod(n, 10)
+ nMod100 := math.Mod(n, 100)
if nMod10 == 1 && nMod100 != 11 {
return locales.PluralRuleOne
@@ -90,36 +90,24 @@ func (en *en_AS) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_AS) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_AS) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_AT/en_AT.go b/en_AT/en_AT.go
index fabaf4ac..4223add7 100644
--- a/en_AT/en_AT.go
+++ b/en_AT/en_AT.go
@@ -90,36 +90,24 @@ func (en *en_AT) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_AT) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_AT) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_AU/en_AU.go b/en_AU/en_AU.go
index 90b624da..0f57438b 100644
--- a/en_AU/en_AU.go
+++ b/en_AU/en_AU.go
@@ -90,36 +90,24 @@ func (en *en_AU) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_AU) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_AU) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_BB/en_BB.go b/en_BB/en_BB.go
index 480cc61b..c4c04664 100644
--- a/en_BB/en_BB.go
+++ b/en_BB/en_BB.go
@@ -66,8 +66,8 @@ func (en *en_BB) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
func (en *en_BB) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
n := math.Abs(num)
- nMod10 := math.Mod(n, 10)
nMod100 := math.Mod(n, 100)
+ nMod10 := math.Mod(n, 10)
if nMod10 == 1 && nMod100 != 11 {
return locales.PluralRuleOne
@@ -90,36 +90,24 @@ func (en *en_BB) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_BB) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_BB) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_BE/en_BE.go b/en_BE/en_BE.go
index 1e33c1ed..c8709036 100644
--- a/en_BE/en_BE.go
+++ b/en_BE/en_BE.go
@@ -90,36 +90,24 @@ func (en *en_BE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_BE) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_BE) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_BI/en_BI.go b/en_BI/en_BI.go
index fb514974..253a1fe7 100644
--- a/en_BI/en_BI.go
+++ b/en_BI/en_BI.go
@@ -90,36 +90,24 @@ func (en *en_BI) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_BI) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_BI) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_BM/en_BM.go b/en_BM/en_BM.go
index f221c8be..68909266 100644
--- a/en_BM/en_BM.go
+++ b/en_BM/en_BM.go
@@ -90,36 +90,24 @@ func (en *en_BM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_BM) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_BM) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_BS/en_BS.go b/en_BS/en_BS.go
index a7f8e691..c5d6e61e 100644
--- a/en_BS/en_BS.go
+++ b/en_BS/en_BS.go
@@ -90,36 +90,24 @@ func (en *en_BS) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_BS) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_BS) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_BW/en_BW.go b/en_BW/en_BW.go
index a150b57d..0941b08e 100644
--- a/en_BW/en_BW.go
+++ b/en_BW/en_BW.go
@@ -90,36 +90,24 @@ func (en *en_BW) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_BW) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_BW) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_BZ/en_BZ.go b/en_BZ/en_BZ.go
index 8a32c168..43c3a09e 100644
--- a/en_BZ/en_BZ.go
+++ b/en_BZ/en_BZ.go
@@ -66,8 +66,8 @@ func (en *en_BZ) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
func (en *en_BZ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
n := math.Abs(num)
- nMod100 := math.Mod(n, 100)
nMod10 := math.Mod(n, 10)
+ nMod100 := math.Mod(n, 100)
if nMod10 == 1 && nMod100 != 11 {
return locales.PluralRuleOne
@@ -90,36 +90,24 @@ func (en *en_BZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_BZ) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_BZ) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_CA/en_CA.go b/en_CA/en_CA.go
index 3030524d..9d653450 100644
--- a/en_CA/en_CA.go
+++ b/en_CA/en_CA.go
@@ -90,36 +90,24 @@ func (en *en_CA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_CA) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_CA) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_CC/en_CC.go b/en_CC/en_CC.go
index e395f908..cc7fe6df 100644
--- a/en_CC/en_CC.go
+++ b/en_CC/en_CC.go
@@ -90,36 +90,24 @@ func (en *en_CC) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_CC) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_CC) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_CH/en_CH.go b/en_CH/en_CH.go
index d95f1e09..4dbe9743 100644
--- a/en_CH/en_CH.go
+++ b/en_CH/en_CH.go
@@ -90,36 +90,24 @@ func (en *en_CH) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_CH) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_CH) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_CK/en_CK.go b/en_CK/en_CK.go
index 14cf09a0..3d7933b0 100644
--- a/en_CK/en_CK.go
+++ b/en_CK/en_CK.go
@@ -66,8 +66,8 @@ func (en *en_CK) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
func (en *en_CK) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
n := math.Abs(num)
- nMod10 := math.Mod(n, 10)
nMod100 := math.Mod(n, 100)
+ nMod10 := math.Mod(n, 10)
if nMod10 == 1 && nMod100 != 11 {
return locales.PluralRuleOne
@@ -90,36 +90,24 @@ func (en *en_CK) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_CK) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_CK) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_CM/en_CM.go b/en_CM/en_CM.go
index fbca1c06..a8f83043 100644
--- a/en_CM/en_CM.go
+++ b/en_CM/en_CM.go
@@ -90,36 +90,24 @@ func (en *en_CM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_CM) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_CM) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_CX/en_CX.go b/en_CX/en_CX.go
index d0a910d6..ba63a4dc 100644
--- a/en_CX/en_CX.go
+++ b/en_CX/en_CX.go
@@ -90,36 +90,24 @@ func (en *en_CX) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_CX) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_CX) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_CY/en_CY.go b/en_CY/en_CY.go
index 8b15c399..94a692b7 100644
--- a/en_CY/en_CY.go
+++ b/en_CY/en_CY.go
@@ -66,8 +66,8 @@ func (en *en_CY) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
func (en *en_CY) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
n := math.Abs(num)
- nMod10 := math.Mod(n, 10)
nMod100 := math.Mod(n, 100)
+ nMod10 := math.Mod(n, 10)
if nMod10 == 1 && nMod100 != 11 {
return locales.PluralRuleOne
@@ -90,36 +90,24 @@ func (en *en_CY) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_CY) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_CY) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_DE/en_DE.go b/en_DE/en_DE.go
index cde69584..f3249a8f 100644
--- a/en_DE/en_DE.go
+++ b/en_DE/en_DE.go
@@ -66,8 +66,8 @@ func (en *en_DE) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
func (en *en_DE) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
n := math.Abs(num)
- nMod10 := math.Mod(n, 10)
nMod100 := math.Mod(n, 100)
+ nMod10 := math.Mod(n, 10)
if nMod10 == 1 && nMod100 != 11 {
return locales.PluralRuleOne
@@ -90,36 +90,24 @@ func (en *en_DE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_DE) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_DE) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_DG/en_DG.go b/en_DG/en_DG.go
index 4d23ea4a..eee57d47 100644
--- a/en_DG/en_DG.go
+++ b/en_DG/en_DG.go
@@ -66,8 +66,8 @@ func (en *en_DG) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
func (en *en_DG) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
n := math.Abs(num)
- nMod100 := math.Mod(n, 100)
nMod10 := math.Mod(n, 10)
+ nMod100 := math.Mod(n, 100)
if nMod10 == 1 && nMod100 != 11 {
return locales.PluralRuleOne
@@ -90,36 +90,24 @@ func (en *en_DG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_DG) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_DG) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_DK/en_DK.go b/en_DK/en_DK.go
index f7cde264..9084f9a3 100644
--- a/en_DK/en_DK.go
+++ b/en_DK/en_DK.go
@@ -90,36 +90,24 @@ func (en *en_DK) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_DK) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_DK) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_DM/en_DM.go b/en_DM/en_DM.go
index a8496e2c..57e01cd0 100644
--- a/en_DM/en_DM.go
+++ b/en_DM/en_DM.go
@@ -90,36 +90,24 @@ func (en *en_DM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_DM) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_DM) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_ER/en_ER.go b/en_ER/en_ER.go
index 9fd188a9..4bf2350f 100644
--- a/en_ER/en_ER.go
+++ b/en_ER/en_ER.go
@@ -90,36 +90,24 @@ func (en *en_ER) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_ER) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_ER) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_FI/en_FI.go b/en_FI/en_FI.go
index cbd0f41c..319cf957 100644
--- a/en_FI/en_FI.go
+++ b/en_FI/en_FI.go
@@ -90,32 +90,23 @@ func (en *en_FI) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_FI) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(en.group) - 1; j >= 0; j-- {
b = append(b, en.group[j])
}
@@ -129,11 +120,14 @@ func (en *en_FI) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_FJ/en_FJ.go b/en_FJ/en_FJ.go
index b5c8d5ba..83fd330b 100644
--- a/en_FJ/en_FJ.go
+++ b/en_FJ/en_FJ.go
@@ -90,36 +90,24 @@ func (en *en_FJ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_FJ) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_FJ) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_FK/en_FK.go b/en_FK/en_FK.go
index 7ae37196..1ab1e1b6 100644
--- a/en_FK/en_FK.go
+++ b/en_FK/en_FK.go
@@ -90,36 +90,24 @@ func (en *en_FK) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_FK) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_FK) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_FM/en_FM.go b/en_FM/en_FM.go
index 257b6cb2..ea09b898 100644
--- a/en_FM/en_FM.go
+++ b/en_FM/en_FM.go
@@ -90,36 +90,24 @@ func (en *en_FM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_FM) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_FM) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_GB/en_GB.go b/en_GB/en_GB.go
index 731d4b76..60c0a5cd 100644
--- a/en_GB/en_GB.go
+++ b/en_GB/en_GB.go
@@ -90,36 +90,24 @@ func (en *en_GB) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_GB) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_GB) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_GD/en_GD.go b/en_GD/en_GD.go
index 45d0c00e..011d6227 100644
--- a/en_GD/en_GD.go
+++ b/en_GD/en_GD.go
@@ -66,8 +66,8 @@ func (en *en_GD) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
func (en *en_GD) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
n := math.Abs(num)
- nMod100 := math.Mod(n, 100)
nMod10 := math.Mod(n, 10)
+ nMod100 := math.Mod(n, 100)
if nMod10 == 1 && nMod100 != 11 {
return locales.PluralRuleOne
@@ -90,36 +90,24 @@ func (en *en_GD) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_GD) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_GD) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_GG/en_GG.go b/en_GG/en_GG.go
index 2b451130..b8b7d1f2 100644
--- a/en_GG/en_GG.go
+++ b/en_GG/en_GG.go
@@ -90,36 +90,24 @@ func (en *en_GG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_GG) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_GG) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_GH/en_GH.go b/en_GH/en_GH.go
index 3aef4133..fc2ff8b6 100644
--- a/en_GH/en_GH.go
+++ b/en_GH/en_GH.go
@@ -90,36 +90,24 @@ func (en *en_GH) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_GH) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_GH) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_GI/en_GI.go b/en_GI/en_GI.go
index 449a4926..14f666d8 100644
--- a/en_GI/en_GI.go
+++ b/en_GI/en_GI.go
@@ -90,36 +90,24 @@ func (en *en_GI) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_GI) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_GI) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_GM/en_GM.go b/en_GM/en_GM.go
index 26e937ee..742aeee3 100644
--- a/en_GM/en_GM.go
+++ b/en_GM/en_GM.go
@@ -90,36 +90,24 @@ func (en *en_GM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_GM) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_GM) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_GU/en_GU.go b/en_GU/en_GU.go
index 54a31dfd..558f5ae1 100644
--- a/en_GU/en_GU.go
+++ b/en_GU/en_GU.go
@@ -90,36 +90,24 @@ func (en *en_GU) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_GU) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_GU) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_GY/en_GY.go b/en_GY/en_GY.go
index 93bbe3f1..f96cb2f6 100644
--- a/en_GY/en_GY.go
+++ b/en_GY/en_GY.go
@@ -66,8 +66,8 @@ func (en *en_GY) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
func (en *en_GY) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
n := math.Abs(num)
- nMod100 := math.Mod(n, 100)
nMod10 := math.Mod(n, 10)
+ nMod100 := math.Mod(n, 100)
if nMod10 == 1 && nMod100 != 11 {
return locales.PluralRuleOne
@@ -90,36 +90,24 @@ func (en *en_GY) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_GY) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_GY) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_HK/en_HK.go b/en_HK/en_HK.go
index 492589d4..6fba1def 100644
--- a/en_HK/en_HK.go
+++ b/en_HK/en_HK.go
@@ -66,8 +66,8 @@ func (en *en_HK) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
func (en *en_HK) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
n := math.Abs(num)
- nMod10 := math.Mod(n, 10)
nMod100 := math.Mod(n, 100)
+ nMod10 := math.Mod(n, 10)
if nMod10 == 1 && nMod100 != 11 {
return locales.PluralRuleOne
@@ -90,36 +90,24 @@ func (en *en_HK) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_HK) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_HK) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_IE/en_IE.go b/en_IE/en_IE.go
index 7ded7a03..53a08d29 100644
--- a/en_IE/en_IE.go
+++ b/en_IE/en_IE.go
@@ -90,36 +90,24 @@ func (en *en_IE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_IE) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_IE) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_IL/en_IL.go b/en_IL/en_IL.go
index 03b59b70..7cb23711 100644
--- a/en_IL/en_IL.go
+++ b/en_IL/en_IL.go
@@ -90,36 +90,24 @@ func (en *en_IL) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_IL) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_IL) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_IM/en_IM.go b/en_IM/en_IM.go
index 2ed730aa..4b0ca810 100644
--- a/en_IM/en_IM.go
+++ b/en_IM/en_IM.go
@@ -66,8 +66,8 @@ func (en *en_IM) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
func (en *en_IM) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
n := math.Abs(num)
- nMod100 := math.Mod(n, 100)
nMod10 := math.Mod(n, 10)
+ nMod100 := math.Mod(n, 100)
if nMod10 == 1 && nMod100 != 11 {
return locales.PluralRuleOne
@@ -90,36 +90,24 @@ func (en *en_IM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_IM) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_IM) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_IN/en_IN.go b/en_IN/en_IN.go
index b427cfa8..043854b9 100644
--- a/en_IN/en_IN.go
+++ b/en_IN/en_IN.go
@@ -90,23 +90,19 @@ func (en *en_IN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_IN) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
+ inSecondary := false
+ groupThreshold := 3
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
@@ -114,13 +110,14 @@ func (en *en_IN) FmtNumber(num float64, v uint64) []byte {
if inWhole {
- if count == 3 {
+ if count == groupThreshold {
+ b = append(b, en.group[0])
+ count = 1
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
+ if !inSecondary {
+ inSecondary = true
+ groupThreshold = 2
}
-
- count = 1
} else {
count++
}
@@ -129,11 +126,14 @@ func (en *en_IN) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_IO/en_IO.go b/en_IO/en_IO.go
index c83d941f..14079f07 100644
--- a/en_IO/en_IO.go
+++ b/en_IO/en_IO.go
@@ -90,36 +90,24 @@ func (en *en_IO) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_IO) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_IO) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_JE/en_JE.go b/en_JE/en_JE.go
index 0263a497..1022c5af 100644
--- a/en_JE/en_JE.go
+++ b/en_JE/en_JE.go
@@ -66,8 +66,8 @@ func (en *en_JE) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
func (en *en_JE) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
n := math.Abs(num)
- nMod10 := math.Mod(n, 10)
nMod100 := math.Mod(n, 100)
+ nMod10 := math.Mod(n, 10)
if nMod10 == 1 && nMod100 != 11 {
return locales.PluralRuleOne
@@ -90,36 +90,24 @@ func (en *en_JE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_JE) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_JE) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_JM/en_JM.go b/en_JM/en_JM.go
index 821540cf..744feb51 100644
--- a/en_JM/en_JM.go
+++ b/en_JM/en_JM.go
@@ -90,36 +90,24 @@ func (en *en_JM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_JM) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_JM) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_KE/en_KE.go b/en_KE/en_KE.go
index 0679f8e4..c20d79bd 100644
--- a/en_KE/en_KE.go
+++ b/en_KE/en_KE.go
@@ -90,36 +90,24 @@ func (en *en_KE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_KE) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_KE) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_KI/en_KI.go b/en_KI/en_KI.go
index 7199fbf2..4de8b6a6 100644
--- a/en_KI/en_KI.go
+++ b/en_KI/en_KI.go
@@ -66,8 +66,8 @@ func (en *en_KI) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
func (en *en_KI) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
n := math.Abs(num)
- nMod100 := math.Mod(n, 100)
nMod10 := math.Mod(n, 10)
+ nMod100 := math.Mod(n, 100)
if nMod10 == 1 && nMod100 != 11 {
return locales.PluralRuleOne
@@ -90,36 +90,24 @@ func (en *en_KI) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_KI) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_KI) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_KN/en_KN.go b/en_KN/en_KN.go
index 4bcd798c..749a570b 100644
--- a/en_KN/en_KN.go
+++ b/en_KN/en_KN.go
@@ -66,8 +66,8 @@ func (en *en_KN) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
func (en *en_KN) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
n := math.Abs(num)
- nMod10 := math.Mod(n, 10)
nMod100 := math.Mod(n, 100)
+ nMod10 := math.Mod(n, 10)
if nMod10 == 1 && nMod100 != 11 {
return locales.PluralRuleOne
@@ -90,36 +90,24 @@ func (en *en_KN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_KN) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_KN) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_KY/en_KY.go b/en_KY/en_KY.go
index 7292246d..2d2555b4 100644
--- a/en_KY/en_KY.go
+++ b/en_KY/en_KY.go
@@ -66,8 +66,8 @@ func (en *en_KY) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
func (en *en_KY) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
n := math.Abs(num)
- nMod10 := math.Mod(n, 10)
nMod100 := math.Mod(n, 100)
+ nMod10 := math.Mod(n, 10)
if nMod10 == 1 && nMod100 != 11 {
return locales.PluralRuleOne
@@ -90,36 +90,24 @@ func (en *en_KY) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_KY) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_KY) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_LC/en_LC.go b/en_LC/en_LC.go
index 04412350..b9243bc1 100644
--- a/en_LC/en_LC.go
+++ b/en_LC/en_LC.go
@@ -90,36 +90,24 @@ func (en *en_LC) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_LC) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_LC) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_LR/en_LR.go b/en_LR/en_LR.go
index a0c2ce45..994aa26c 100644
--- a/en_LR/en_LR.go
+++ b/en_LR/en_LR.go
@@ -90,36 +90,24 @@ func (en *en_LR) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_LR) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_LR) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_LS/en_LS.go b/en_LS/en_LS.go
index 529a99a1..a43ad93a 100644
--- a/en_LS/en_LS.go
+++ b/en_LS/en_LS.go
@@ -90,36 +90,24 @@ func (en *en_LS) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_LS) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_LS) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_MG/en_MG.go b/en_MG/en_MG.go
index 4c6fdaf1..89be3d4f 100644
--- a/en_MG/en_MG.go
+++ b/en_MG/en_MG.go
@@ -66,8 +66,8 @@ func (en *en_MG) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
func (en *en_MG) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
n := math.Abs(num)
- nMod10 := math.Mod(n, 10)
nMod100 := math.Mod(n, 100)
+ nMod10 := math.Mod(n, 10)
if nMod10 == 1 && nMod100 != 11 {
return locales.PluralRuleOne
@@ -90,36 +90,24 @@ func (en *en_MG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_MG) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_MG) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_MH/en_MH.go b/en_MH/en_MH.go
index f4a69357..8c8d44bc 100644
--- a/en_MH/en_MH.go
+++ b/en_MH/en_MH.go
@@ -90,36 +90,24 @@ func (en *en_MH) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_MH) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_MH) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_MO/en_MO.go b/en_MO/en_MO.go
index 30c8092b..1c72a979 100644
--- a/en_MO/en_MO.go
+++ b/en_MO/en_MO.go
@@ -90,36 +90,24 @@ func (en *en_MO) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_MO) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_MO) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_MP/en_MP.go b/en_MP/en_MP.go
index 898f9594..7e733c46 100644
--- a/en_MP/en_MP.go
+++ b/en_MP/en_MP.go
@@ -66,8 +66,8 @@ func (en *en_MP) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
func (en *en_MP) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
n := math.Abs(num)
- nMod10 := math.Mod(n, 10)
nMod100 := math.Mod(n, 100)
+ nMod10 := math.Mod(n, 10)
if nMod10 == 1 && nMod100 != 11 {
return locales.PluralRuleOne
@@ -90,36 +90,24 @@ func (en *en_MP) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_MP) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_MP) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_MS/en_MS.go b/en_MS/en_MS.go
index 7eb21755..ec8d7ffa 100644
--- a/en_MS/en_MS.go
+++ b/en_MS/en_MS.go
@@ -90,36 +90,24 @@ func (en *en_MS) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_MS) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_MS) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_MT/en_MT.go b/en_MT/en_MT.go
index 64cb1bcc..2f81347e 100644
--- a/en_MT/en_MT.go
+++ b/en_MT/en_MT.go
@@ -66,8 +66,8 @@ func (en *en_MT) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
func (en *en_MT) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
n := math.Abs(num)
- nMod10 := math.Mod(n, 10)
nMod100 := math.Mod(n, 100)
+ nMod10 := math.Mod(n, 10)
if nMod10 == 1 && nMod100 != 11 {
return locales.PluralRuleOne
@@ -90,36 +90,24 @@ func (en *en_MT) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_MT) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_MT) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_MU/en_MU.go b/en_MU/en_MU.go
index a53b28f8..52e4cc15 100644
--- a/en_MU/en_MU.go
+++ b/en_MU/en_MU.go
@@ -66,8 +66,8 @@ func (en *en_MU) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
func (en *en_MU) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
n := math.Abs(num)
- nMod100 := math.Mod(n, 100)
nMod10 := math.Mod(n, 10)
+ nMod100 := math.Mod(n, 100)
if nMod10 == 1 && nMod100 != 11 {
return locales.PluralRuleOne
@@ -90,36 +90,24 @@ func (en *en_MU) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_MU) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_MU) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_MW/en_MW.go b/en_MW/en_MW.go
index e557740f..466ac98a 100644
--- a/en_MW/en_MW.go
+++ b/en_MW/en_MW.go
@@ -90,36 +90,24 @@ func (en *en_MW) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_MW) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_MW) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_MY/en_MY.go b/en_MY/en_MY.go
index abbbc10e..efaa5609 100644
--- a/en_MY/en_MY.go
+++ b/en_MY/en_MY.go
@@ -90,36 +90,24 @@ func (en *en_MY) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_MY) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_MY) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_NA/en_NA.go b/en_NA/en_NA.go
index 8795aed2..d1b57e63 100644
--- a/en_NA/en_NA.go
+++ b/en_NA/en_NA.go
@@ -90,36 +90,24 @@ func (en *en_NA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_NA) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_NA) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_NF/en_NF.go b/en_NF/en_NF.go
index 204b948f..495f2cd9 100644
--- a/en_NF/en_NF.go
+++ b/en_NF/en_NF.go
@@ -90,36 +90,24 @@ func (en *en_NF) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_NF) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_NF) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_NG/en_NG.go b/en_NG/en_NG.go
index 5c863a7c..e616151a 100644
--- a/en_NG/en_NG.go
+++ b/en_NG/en_NG.go
@@ -90,36 +90,24 @@ func (en *en_NG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_NG) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_NG) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_NL/en_NL.go b/en_NL/en_NL.go
index 61c6b69e..84dba0df 100644
--- a/en_NL/en_NL.go
+++ b/en_NL/en_NL.go
@@ -90,36 +90,24 @@ func (en *en_NL) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_NL) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_NL) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_NR/en_NR.go b/en_NR/en_NR.go
index dd0f8e7e..25a8847f 100644
--- a/en_NR/en_NR.go
+++ b/en_NR/en_NR.go
@@ -90,36 +90,24 @@ func (en *en_NR) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_NR) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_NR) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_NU/en_NU.go b/en_NU/en_NU.go
index c64fa2d6..e185e360 100644
--- a/en_NU/en_NU.go
+++ b/en_NU/en_NU.go
@@ -66,8 +66,8 @@ func (en *en_NU) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
func (en *en_NU) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
n := math.Abs(num)
- nMod100 := math.Mod(n, 100)
nMod10 := math.Mod(n, 10)
+ nMod100 := math.Mod(n, 100)
if nMod10 == 1 && nMod100 != 11 {
return locales.PluralRuleOne
@@ -90,36 +90,24 @@ func (en *en_NU) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_NU) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_NU) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_NZ/en_NZ.go b/en_NZ/en_NZ.go
index 56becca1..29b02990 100644
--- a/en_NZ/en_NZ.go
+++ b/en_NZ/en_NZ.go
@@ -66,8 +66,8 @@ func (en *en_NZ) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
func (en *en_NZ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
n := math.Abs(num)
- nMod10 := math.Mod(n, 10)
nMod100 := math.Mod(n, 100)
+ nMod10 := math.Mod(n, 10)
if nMod10 == 1 && nMod100 != 11 {
return locales.PluralRuleOne
@@ -90,36 +90,24 @@ func (en *en_NZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_NZ) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_NZ) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_PG/en_PG.go b/en_PG/en_PG.go
index 08025985..e336da5a 100644
--- a/en_PG/en_PG.go
+++ b/en_PG/en_PG.go
@@ -90,36 +90,24 @@ func (en *en_PG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_PG) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_PG) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_PH/en_PH.go b/en_PH/en_PH.go
index e8ccf0c3..d058bffe 100644
--- a/en_PH/en_PH.go
+++ b/en_PH/en_PH.go
@@ -90,36 +90,24 @@ func (en *en_PH) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_PH) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_PH) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_PK/en_PK.go b/en_PK/en_PK.go
index 62469e6e..8d99884a 100644
--- a/en_PK/en_PK.go
+++ b/en_PK/en_PK.go
@@ -90,36 +90,24 @@ func (en *en_PK) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_PK) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_PK) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_PN/en_PN.go b/en_PN/en_PN.go
index 946c989e..7a4c694b 100644
--- a/en_PN/en_PN.go
+++ b/en_PN/en_PN.go
@@ -90,36 +90,24 @@ func (en *en_PN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_PN) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_PN) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_PR/en_PR.go b/en_PR/en_PR.go
index 6f2f03bb..5d04b043 100644
--- a/en_PR/en_PR.go
+++ b/en_PR/en_PR.go
@@ -90,36 +90,24 @@ func (en *en_PR) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_PR) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_PR) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_PW/en_PW.go b/en_PW/en_PW.go
index fddfada8..1c091d1e 100644
--- a/en_PW/en_PW.go
+++ b/en_PW/en_PW.go
@@ -90,36 +90,24 @@ func (en *en_PW) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_PW) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_PW) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_RW/en_RW.go b/en_RW/en_RW.go
index 2c22d59a..638e2ab9 100644
--- a/en_RW/en_RW.go
+++ b/en_RW/en_RW.go
@@ -90,36 +90,24 @@ func (en *en_RW) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_RW) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_RW) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_SB/en_SB.go b/en_SB/en_SB.go
index f8fc9872..b66fb3be 100644
--- a/en_SB/en_SB.go
+++ b/en_SB/en_SB.go
@@ -90,36 +90,24 @@ func (en *en_SB) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_SB) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_SB) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_SC/en_SC.go b/en_SC/en_SC.go
index 5f65f101..3a918b05 100644
--- a/en_SC/en_SC.go
+++ b/en_SC/en_SC.go
@@ -66,8 +66,8 @@ func (en *en_SC) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
func (en *en_SC) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
n := math.Abs(num)
- nMod10 := math.Mod(n, 10)
nMod100 := math.Mod(n, 100)
+ nMod10 := math.Mod(n, 10)
if nMod10 == 1 && nMod100 != 11 {
return locales.PluralRuleOne
@@ -90,36 +90,24 @@ func (en *en_SC) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_SC) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_SC) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_SD/en_SD.go b/en_SD/en_SD.go
index eb5491a2..6f7c89a6 100644
--- a/en_SD/en_SD.go
+++ b/en_SD/en_SD.go
@@ -66,8 +66,8 @@ func (en *en_SD) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
func (en *en_SD) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
n := math.Abs(num)
- nMod100 := math.Mod(n, 100)
nMod10 := math.Mod(n, 10)
+ nMod100 := math.Mod(n, 100)
if nMod10 == 1 && nMod100 != 11 {
return locales.PluralRuleOne
@@ -90,36 +90,24 @@ func (en *en_SD) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_SD) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_SD) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_SE/en_SE.go b/en_SE/en_SE.go
index 160a9a3b..3920851f 100644
--- a/en_SE/en_SE.go
+++ b/en_SE/en_SE.go
@@ -90,32 +90,23 @@ func (en *en_SE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_SE) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(en.group) - 1; j >= 0; j-- {
b = append(b, en.group[j])
}
@@ -129,11 +120,14 @@ func (en *en_SE) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_SG/en_SG.go b/en_SG/en_SG.go
index aa3e507e..30f47783 100644
--- a/en_SG/en_SG.go
+++ b/en_SG/en_SG.go
@@ -90,36 +90,24 @@ func (en *en_SG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_SG) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_SG) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_SH/en_SH.go b/en_SH/en_SH.go
index c8f3a186..c9fa5e68 100644
--- a/en_SH/en_SH.go
+++ b/en_SH/en_SH.go
@@ -66,8 +66,8 @@ func (en *en_SH) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
func (en *en_SH) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
n := math.Abs(num)
- nMod100 := math.Mod(n, 100)
nMod10 := math.Mod(n, 10)
+ nMod100 := math.Mod(n, 100)
if nMod10 == 1 && nMod100 != 11 {
return locales.PluralRuleOne
@@ -90,36 +90,24 @@ func (en *en_SH) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_SH) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_SH) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_SI/en_SI.go b/en_SI/en_SI.go
index 9072e488..aa35ca1f 100644
--- a/en_SI/en_SI.go
+++ b/en_SI/en_SI.go
@@ -90,36 +90,24 @@ func (en *en_SI) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_SI) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_SI) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_SL/en_SL.go b/en_SL/en_SL.go
index fe527b77..e4916ca2 100644
--- a/en_SL/en_SL.go
+++ b/en_SL/en_SL.go
@@ -90,36 +90,24 @@ func (en *en_SL) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_SL) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_SL) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_SS/en_SS.go b/en_SS/en_SS.go
index 7208f65f..2d554caa 100644
--- a/en_SS/en_SS.go
+++ b/en_SS/en_SS.go
@@ -66,8 +66,8 @@ func (en *en_SS) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
func (en *en_SS) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
n := math.Abs(num)
- nMod100 := math.Mod(n, 100)
nMod10 := math.Mod(n, 10)
+ nMod100 := math.Mod(n, 100)
if nMod10 == 1 && nMod100 != 11 {
return locales.PluralRuleOne
@@ -90,36 +90,24 @@ func (en *en_SS) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_SS) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_SS) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_SX/en_SX.go b/en_SX/en_SX.go
index 6f7d39eb..0141baaf 100644
--- a/en_SX/en_SX.go
+++ b/en_SX/en_SX.go
@@ -66,8 +66,8 @@ func (en *en_SX) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
func (en *en_SX) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
n := math.Abs(num)
- nMod10 := math.Mod(n, 10)
nMod100 := math.Mod(n, 100)
+ nMod10 := math.Mod(n, 10)
if nMod10 == 1 && nMod100 != 11 {
return locales.PluralRuleOne
@@ -90,36 +90,24 @@ func (en *en_SX) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_SX) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_SX) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_SZ/en_SZ.go b/en_SZ/en_SZ.go
index afd891ba..ccef0ede 100644
--- a/en_SZ/en_SZ.go
+++ b/en_SZ/en_SZ.go
@@ -90,36 +90,24 @@ func (en *en_SZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_SZ) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_SZ) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_TC/en_TC.go b/en_TC/en_TC.go
index c0ae536c..5ec3aace 100644
--- a/en_TC/en_TC.go
+++ b/en_TC/en_TC.go
@@ -90,36 +90,24 @@ func (en *en_TC) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_TC) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_TC) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_TK/en_TK.go b/en_TK/en_TK.go
index 1281eda0..b6da1912 100644
--- a/en_TK/en_TK.go
+++ b/en_TK/en_TK.go
@@ -90,36 +90,24 @@ func (en *en_TK) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_TK) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_TK) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_TO/en_TO.go b/en_TO/en_TO.go
index 8cde1862..4318a290 100644
--- a/en_TO/en_TO.go
+++ b/en_TO/en_TO.go
@@ -90,36 +90,24 @@ func (en *en_TO) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_TO) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_TO) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_TT/en_TT.go b/en_TT/en_TT.go
index d7f0a43c..8c39fcf6 100644
--- a/en_TT/en_TT.go
+++ b/en_TT/en_TT.go
@@ -90,36 +90,24 @@ func (en *en_TT) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_TT) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_TT) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_TV/en_TV.go b/en_TV/en_TV.go
index 9d79119a..fd775b87 100644
--- a/en_TV/en_TV.go
+++ b/en_TV/en_TV.go
@@ -66,8 +66,8 @@ func (en *en_TV) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
func (en *en_TV) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
n := math.Abs(num)
- nMod10 := math.Mod(n, 10)
nMod100 := math.Mod(n, 100)
+ nMod10 := math.Mod(n, 10)
if nMod10 == 1 && nMod100 != 11 {
return locales.PluralRuleOne
@@ -90,36 +90,24 @@ func (en *en_TV) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_TV) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_TV) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_TZ/en_TZ.go b/en_TZ/en_TZ.go
index 115f1127..db2dd7c8 100644
--- a/en_TZ/en_TZ.go
+++ b/en_TZ/en_TZ.go
@@ -90,36 +90,24 @@ func (en *en_TZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_TZ) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_TZ) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_UG/en_UG.go b/en_UG/en_UG.go
index 4d336346..b1034f9c 100644
--- a/en_UG/en_UG.go
+++ b/en_UG/en_UG.go
@@ -66,8 +66,8 @@ func (en *en_UG) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
func (en *en_UG) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
n := math.Abs(num)
- nMod10 := math.Mod(n, 10)
nMod100 := math.Mod(n, 100)
+ nMod10 := math.Mod(n, 10)
if nMod10 == 1 && nMod100 != 11 {
return locales.PluralRuleOne
@@ -90,36 +90,24 @@ func (en *en_UG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_UG) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_UG) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_UM/en_UM.go b/en_UM/en_UM.go
index a5973990..9024068c 100644
--- a/en_UM/en_UM.go
+++ b/en_UM/en_UM.go
@@ -90,36 +90,24 @@ func (en *en_UM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_UM) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_UM) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_US/en_US.go b/en_US/en_US.go
index f58a3147..0897990a 100644
--- a/en_US/en_US.go
+++ b/en_US/en_US.go
@@ -66,8 +66,8 @@ func (en *en_US) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
func (en *en_US) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
n := math.Abs(num)
- nMod10 := math.Mod(n, 10)
nMod100 := math.Mod(n, 100)
+ nMod10 := math.Mod(n, 10)
if nMod10 == 1 && nMod100 != 11 {
return locales.PluralRuleOne
@@ -90,36 +90,24 @@ func (en *en_US) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_US) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_US) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_US_POSIX/en_US_POSIX.go b/en_US_POSIX/en_US_POSIX.go
index 5732b0d9..266fe518 100644
--- a/en_US_POSIX/en_US_POSIX.go
+++ b/en_US_POSIX/en_US_POSIX.go
@@ -66,8 +66,8 @@ func (en *en_US_POSIX) CardinalPluralRule(num float64, v uint64) locales.PluralR
func (en *en_US_POSIX) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
n := math.Abs(num)
- nMod10 := math.Mod(n, 10)
nMod100 := math.Mod(n, 100)
+ nMod10 := math.Mod(n, 10)
if nMod10 == 1 && nMod100 != 11 {
return locales.PluralRuleOne
@@ -90,8 +90,7 @@ func (en *en_US_POSIX) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2
// avoid allocations; otherwise just cast as string.
func (en *en_US_POSIX) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal)
b := make([]byte, 0, l)
@@ -99,22 +98,21 @@ func (en *en_US_POSIX) FmtNumber(num float64, v uint64) []byte {
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
continue
}
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_VC/en_VC.go b/en_VC/en_VC.go
index c7f677e6..639bba9e 100644
--- a/en_VC/en_VC.go
+++ b/en_VC/en_VC.go
@@ -90,36 +90,24 @@ func (en *en_VC) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_VC) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_VC) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_VG/en_VG.go b/en_VG/en_VG.go
index 10e55e7f..3794c5a3 100644
--- a/en_VG/en_VG.go
+++ b/en_VG/en_VG.go
@@ -90,36 +90,24 @@ func (en *en_VG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_VG) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_VG) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_VI/en_VI.go b/en_VI/en_VI.go
index 37419955..272dcf35 100644
--- a/en_VI/en_VI.go
+++ b/en_VI/en_VI.go
@@ -66,8 +66,8 @@ func (en *en_VI) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
func (en *en_VI) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
n := math.Abs(num)
- nMod100 := math.Mod(n, 100)
nMod10 := math.Mod(n, 10)
+ nMod100 := math.Mod(n, 100)
if nMod10 == 1 && nMod100 != 11 {
return locales.PluralRuleOne
@@ -90,36 +90,24 @@ func (en *en_VI) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_VI) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_VI) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_VU/en_VU.go b/en_VU/en_VU.go
index ff8e8995..ae797ea1 100644
--- a/en_VU/en_VU.go
+++ b/en_VU/en_VU.go
@@ -66,8 +66,8 @@ func (en *en_VU) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
func (en *en_VU) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
n := math.Abs(num)
- nMod10 := math.Mod(n, 10)
nMod100 := math.Mod(n, 100)
+ nMod10 := math.Mod(n, 10)
if nMod10 == 1 && nMod100 != 11 {
return locales.PluralRuleOne
@@ -90,36 +90,24 @@ func (en *en_VU) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_VU) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_VU) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_WS/en_WS.go b/en_WS/en_WS.go
index c1df081e..f979243e 100644
--- a/en_WS/en_WS.go
+++ b/en_WS/en_WS.go
@@ -66,8 +66,8 @@ func (en *en_WS) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
func (en *en_WS) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
n := math.Abs(num)
- nMod100 := math.Mod(n, 100)
nMod10 := math.Mod(n, 10)
+ nMod100 := math.Mod(n, 100)
if nMod10 == 1 && nMod100 != 11 {
return locales.PluralRuleOne
@@ -90,36 +90,24 @@ func (en *en_WS) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_WS) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_WS) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_ZA/en_ZA.go b/en_ZA/en_ZA.go
index eebec37e..d7ce3f1c 100644
--- a/en_ZA/en_ZA.go
+++ b/en_ZA/en_ZA.go
@@ -90,32 +90,23 @@ func (en *en_ZA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_ZA) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(en.group) - 1; j >= 0; j-- {
b = append(b, en.group[j])
}
@@ -129,11 +120,14 @@ func (en *en_ZA) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_ZM/en_ZM.go b/en_ZM/en_ZM.go
index 4ff4b4e0..81c3dbd4 100644
--- a/en_ZM/en_ZM.go
+++ b/en_ZM/en_ZM.go
@@ -90,36 +90,24 @@ func (en *en_ZM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_ZM) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_ZM) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/en_ZW/en_ZW.go b/en_ZW/en_ZW.go
index 7a4df7e3..784a9e4c 100644
--- a/en_ZW/en_ZW.go
+++ b/en_ZW/en_ZW.go
@@ -66,8 +66,8 @@ func (en *en_ZW) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
func (en *en_ZW) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
n := math.Abs(num)
- nMod10 := math.Mod(n, 10)
nMod100 := math.Mod(n, 100)
+ nMod10 := math.Mod(n, 10)
if nMod10 == 1 && nMod100 != 11 {
return locales.PluralRuleOne
@@ -90,36 +90,24 @@ func (en *en_ZW) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (en *en_ZW) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(en.decimal) + len(en.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(en.decimal) - 1; j >= 0; j-- {
- b = append(b, en.decimal[j])
- }
-
+ b = append(b, en.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(en.group) - 1; j >= 0; j-- {
- b = append(b, en.group[j])
- }
-
+ b = append(b, en.group[0])
count = 1
} else {
count++
@@ -129,11 +117,14 @@ func (en *en_ZW) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, en.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/eo/eo.go b/eo/eo.go
index cb5ef76d..e610d1a9 100644
--- a/eo/eo.go
+++ b/eo/eo.go
@@ -76,32 +76,23 @@ func (eo *eo) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (eo *eo) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(eo.decimal) + len(eo.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(eo.decimal) - 1; j >= 0; j-- {
- b = append(b, eo.decimal[j])
- }
-
+ b = append(b, eo.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(eo.group) - 1; j >= 0; j-- {
b = append(b, eo.group[j])
}
@@ -115,11 +106,16 @@ func (eo *eo) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(eo.minus) - 1; j >= 0; j-- {
+ b = append(b, eo.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/eo_001/eo_001.go b/eo_001/eo_001.go
index 5c688c06..e0f7fedd 100644
--- a/eo_001/eo_001.go
+++ b/eo_001/eo_001.go
@@ -76,32 +76,23 @@ func (eo *eo_001) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint
// avoid allocations; otherwise just cast as string.
func (eo *eo_001) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(eo.decimal) + len(eo.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(eo.decimal) - 1; j >= 0; j-- {
- b = append(b, eo.decimal[j])
- }
-
+ b = append(b, eo.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(eo.group) - 1; j >= 0; j-- {
b = append(b, eo.group[j])
}
@@ -115,11 +106,16 @@ func (eo *eo_001) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(eo.minus) - 1; j >= 0; j-- {
+ b = append(b, eo.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/es/es.go b/es/es.go
index 0cebd4d5..2b5af50c 100644
--- a/es/es.go
+++ b/es/es.go
@@ -76,36 +76,24 @@ func (es *es) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (es *es) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(es.decimal) + len(es.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(es.decimal) - 1; j >= 0; j-- {
- b = append(b, es.decimal[j])
- }
-
+ b = append(b, es.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(es.group) - 1; j >= 0; j-- {
- b = append(b, es.group[j])
- }
-
+ b = append(b, es.group[0])
count = 1
} else {
count++
@@ -115,11 +103,14 @@ func (es *es) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, es.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/es_419/es_419.go b/es_419/es_419.go
index b20a620a..50d50322 100644
--- a/es_419/es_419.go
+++ b/es_419/es_419.go
@@ -76,36 +76,24 @@ func (es *es_419) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint
// avoid allocations; otherwise just cast as string.
func (es *es_419) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(es.decimal) + len(es.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(es.decimal) - 1; j >= 0; j-- {
- b = append(b, es.decimal[j])
- }
-
+ b = append(b, es.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(es.group) - 1; j >= 0; j-- {
- b = append(b, es.group[j])
- }
-
+ b = append(b, es.group[0])
count = 1
} else {
count++
@@ -115,11 +103,14 @@ func (es *es_419) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, es.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/es_AR/es_AR.go b/es_AR/es_AR.go
index 62dd29b9..d00d1a8b 100644
--- a/es_AR/es_AR.go
+++ b/es_AR/es_AR.go
@@ -76,36 +76,24 @@ func (es *es_AR) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (es *es_AR) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(es.decimal) + len(es.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(es.decimal) - 1; j >= 0; j-- {
- b = append(b, es.decimal[j])
- }
-
+ b = append(b, es.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(es.group) - 1; j >= 0; j-- {
- b = append(b, es.group[j])
- }
-
+ b = append(b, es.group[0])
count = 1
} else {
count++
@@ -115,11 +103,14 @@ func (es *es_AR) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, es.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/es_BO/es_BO.go b/es_BO/es_BO.go
index 080dc038..a7a98cd7 100644
--- a/es_BO/es_BO.go
+++ b/es_BO/es_BO.go
@@ -76,36 +76,24 @@ func (es *es_BO) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (es *es_BO) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(es.decimal) + len(es.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(es.decimal) - 1; j >= 0; j-- {
- b = append(b, es.decimal[j])
- }
-
+ b = append(b, es.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(es.group) - 1; j >= 0; j-- {
- b = append(b, es.group[j])
- }
-
+ b = append(b, es.group[0])
count = 1
} else {
count++
@@ -115,11 +103,14 @@ func (es *es_BO) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, es.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/es_BR/es_BR.go b/es_BR/es_BR.go
index f44f6370..798e1d41 100644
--- a/es_BR/es_BR.go
+++ b/es_BR/es_BR.go
@@ -76,36 +76,24 @@ func (es *es_BR) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (es *es_BR) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(es.decimal) + len(es.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(es.decimal) - 1; j >= 0; j-- {
- b = append(b, es.decimal[j])
- }
-
+ b = append(b, es.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(es.group) - 1; j >= 0; j-- {
- b = append(b, es.group[j])
- }
-
+ b = append(b, es.group[0])
count = 1
} else {
count++
@@ -115,11 +103,14 @@ func (es *es_BR) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, es.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/es_CL/es_CL.go b/es_CL/es_CL.go
index c111175c..a1db66b4 100644
--- a/es_CL/es_CL.go
+++ b/es_CL/es_CL.go
@@ -76,36 +76,24 @@ func (es *es_CL) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (es *es_CL) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(es.decimal) + len(es.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(es.decimal) - 1; j >= 0; j-- {
- b = append(b, es.decimal[j])
- }
-
+ b = append(b, es.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(es.group) - 1; j >= 0; j-- {
- b = append(b, es.group[j])
- }
-
+ b = append(b, es.group[0])
count = 1
} else {
count++
@@ -115,11 +103,14 @@ func (es *es_CL) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, es.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/es_CO/es_CO.go b/es_CO/es_CO.go
index ed5d8ae4..f6ae6212 100644
--- a/es_CO/es_CO.go
+++ b/es_CO/es_CO.go
@@ -76,36 +76,24 @@ func (es *es_CO) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (es *es_CO) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(es.decimal) + len(es.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(es.decimal) - 1; j >= 0; j-- {
- b = append(b, es.decimal[j])
- }
-
+ b = append(b, es.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(es.group) - 1; j >= 0; j-- {
- b = append(b, es.group[j])
- }
-
+ b = append(b, es.group[0])
count = 1
} else {
count++
@@ -115,11 +103,14 @@ func (es *es_CO) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, es.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/es_CR/es_CR.go b/es_CR/es_CR.go
index fc1abb9e..b1371395 100644
--- a/es_CR/es_CR.go
+++ b/es_CR/es_CR.go
@@ -76,32 +76,23 @@ func (es *es_CR) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (es *es_CR) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(es.decimal) + len(es.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(es.decimal) - 1; j >= 0; j-- {
- b = append(b, es.decimal[j])
- }
-
+ b = append(b, es.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(es.group) - 1; j >= 0; j-- {
b = append(b, es.group[j])
}
@@ -115,11 +106,14 @@ func (es *es_CR) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, es.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/es_CU/es_CU.go b/es_CU/es_CU.go
index 92f4ed36..3e9dcd94 100644
--- a/es_CU/es_CU.go
+++ b/es_CU/es_CU.go
@@ -76,36 +76,24 @@ func (es *es_CU) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (es *es_CU) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(es.decimal) + len(es.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(es.decimal) - 1; j >= 0; j-- {
- b = append(b, es.decimal[j])
- }
-
+ b = append(b, es.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(es.group) - 1; j >= 0; j-- {
- b = append(b, es.group[j])
- }
-
+ b = append(b, es.group[0])
count = 1
} else {
count++
@@ -115,11 +103,14 @@ func (es *es_CU) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, es.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/es_DO/es_DO.go b/es_DO/es_DO.go
index 9df2d352..08bfaeb3 100644
--- a/es_DO/es_DO.go
+++ b/es_DO/es_DO.go
@@ -76,36 +76,24 @@ func (es *es_DO) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (es *es_DO) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(es.decimal) + len(es.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(es.decimal) - 1; j >= 0; j-- {
- b = append(b, es.decimal[j])
- }
-
+ b = append(b, es.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(es.group) - 1; j >= 0; j-- {
- b = append(b, es.group[j])
- }
-
+ b = append(b, es.group[0])
count = 1
} else {
count++
@@ -115,11 +103,14 @@ func (es *es_DO) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, es.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/es_EA/es_EA.go b/es_EA/es_EA.go
index 30aa32fc..91ae4cf2 100644
--- a/es_EA/es_EA.go
+++ b/es_EA/es_EA.go
@@ -76,36 +76,24 @@ func (es *es_EA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (es *es_EA) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(es.decimal) + len(es.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(es.decimal) - 1; j >= 0; j-- {
- b = append(b, es.decimal[j])
- }
-
+ b = append(b, es.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(es.group) - 1; j >= 0; j-- {
- b = append(b, es.group[j])
- }
-
+ b = append(b, es.group[0])
count = 1
} else {
count++
@@ -115,11 +103,14 @@ func (es *es_EA) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, es.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/es_EC/es_EC.go b/es_EC/es_EC.go
index 462ef231..8ae865de 100644
--- a/es_EC/es_EC.go
+++ b/es_EC/es_EC.go
@@ -76,36 +76,24 @@ func (es *es_EC) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (es *es_EC) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(es.decimal) + len(es.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(es.decimal) - 1; j >= 0; j-- {
- b = append(b, es.decimal[j])
- }
-
+ b = append(b, es.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(es.group) - 1; j >= 0; j-- {
- b = append(b, es.group[j])
- }
-
+ b = append(b, es.group[0])
count = 1
} else {
count++
@@ -115,11 +103,14 @@ func (es *es_EC) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, es.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/es_ES/es_ES.go b/es_ES/es_ES.go
index 24ed7721..4fddacc9 100644
--- a/es_ES/es_ES.go
+++ b/es_ES/es_ES.go
@@ -76,36 +76,24 @@ func (es *es_ES) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (es *es_ES) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(es.decimal) + len(es.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(es.decimal) - 1; j >= 0; j-- {
- b = append(b, es.decimal[j])
- }
-
+ b = append(b, es.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(es.group) - 1; j >= 0; j-- {
- b = append(b, es.group[j])
- }
-
+ b = append(b, es.group[0])
count = 1
} else {
count++
@@ -115,11 +103,14 @@ func (es *es_ES) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, es.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/es_GQ/es_GQ.go b/es_GQ/es_GQ.go
index 60f338ec..42385ffd 100644
--- a/es_GQ/es_GQ.go
+++ b/es_GQ/es_GQ.go
@@ -76,36 +76,24 @@ func (es *es_GQ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (es *es_GQ) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(es.decimal) + len(es.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(es.decimal) - 1; j >= 0; j-- {
- b = append(b, es.decimal[j])
- }
-
+ b = append(b, es.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(es.group) - 1; j >= 0; j-- {
- b = append(b, es.group[j])
- }
-
+ b = append(b, es.group[0])
count = 1
} else {
count++
@@ -115,11 +103,14 @@ func (es *es_GQ) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, es.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/es_GT/es_GT.go b/es_GT/es_GT.go
index 60e0dd9a..e3d0e71a 100644
--- a/es_GT/es_GT.go
+++ b/es_GT/es_GT.go
@@ -76,36 +76,24 @@ func (es *es_GT) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (es *es_GT) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(es.decimal) + len(es.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(es.decimal) - 1; j >= 0; j-- {
- b = append(b, es.decimal[j])
- }
-
+ b = append(b, es.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(es.group) - 1; j >= 0; j-- {
- b = append(b, es.group[j])
- }
-
+ b = append(b, es.group[0])
count = 1
} else {
count++
@@ -115,11 +103,14 @@ func (es *es_GT) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, es.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/es_HN/es_HN.go b/es_HN/es_HN.go
index 7b26019e..fceb5702 100644
--- a/es_HN/es_HN.go
+++ b/es_HN/es_HN.go
@@ -76,36 +76,24 @@ func (es *es_HN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (es *es_HN) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(es.decimal) + len(es.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(es.decimal) - 1; j >= 0; j-- {
- b = append(b, es.decimal[j])
- }
-
+ b = append(b, es.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(es.group) - 1; j >= 0; j-- {
- b = append(b, es.group[j])
- }
-
+ b = append(b, es.group[0])
count = 1
} else {
count++
@@ -115,11 +103,14 @@ func (es *es_HN) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, es.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/es_IC/es_IC.go b/es_IC/es_IC.go
index b62b8775..49ba46a2 100644
--- a/es_IC/es_IC.go
+++ b/es_IC/es_IC.go
@@ -76,36 +76,24 @@ func (es *es_IC) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (es *es_IC) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(es.decimal) + len(es.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(es.decimal) - 1; j >= 0; j-- {
- b = append(b, es.decimal[j])
- }
-
+ b = append(b, es.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(es.group) - 1; j >= 0; j-- {
- b = append(b, es.group[j])
- }
-
+ b = append(b, es.group[0])
count = 1
} else {
count++
@@ -115,11 +103,14 @@ func (es *es_IC) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, es.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/es_MX/es_MX.go b/es_MX/es_MX.go
index 2e569d37..c6776a97 100644
--- a/es_MX/es_MX.go
+++ b/es_MX/es_MX.go
@@ -76,36 +76,24 @@ func (es *es_MX) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (es *es_MX) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(es.decimal) + len(es.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(es.decimal) - 1; j >= 0; j-- {
- b = append(b, es.decimal[j])
- }
-
+ b = append(b, es.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(es.group) - 1; j >= 0; j-- {
- b = append(b, es.group[j])
- }
-
+ b = append(b, es.group[0])
count = 1
} else {
count++
@@ -115,11 +103,14 @@ func (es *es_MX) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, es.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/es_NI/es_NI.go b/es_NI/es_NI.go
index bc2e1fbc..ec202312 100644
--- a/es_NI/es_NI.go
+++ b/es_NI/es_NI.go
@@ -76,36 +76,24 @@ func (es *es_NI) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (es *es_NI) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(es.decimal) + len(es.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(es.decimal) - 1; j >= 0; j-- {
- b = append(b, es.decimal[j])
- }
-
+ b = append(b, es.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(es.group) - 1; j >= 0; j-- {
- b = append(b, es.group[j])
- }
-
+ b = append(b, es.group[0])
count = 1
} else {
count++
@@ -115,11 +103,14 @@ func (es *es_NI) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, es.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/es_PA/es_PA.go b/es_PA/es_PA.go
index 867e687b..49f999fe 100644
--- a/es_PA/es_PA.go
+++ b/es_PA/es_PA.go
@@ -76,36 +76,24 @@ func (es *es_PA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (es *es_PA) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(es.decimal) + len(es.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(es.decimal) - 1; j >= 0; j-- {
- b = append(b, es.decimal[j])
- }
-
+ b = append(b, es.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(es.group) - 1; j >= 0; j-- {
- b = append(b, es.group[j])
- }
-
+ b = append(b, es.group[0])
count = 1
} else {
count++
@@ -115,11 +103,14 @@ func (es *es_PA) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, es.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/es_PE/es_PE.go b/es_PE/es_PE.go
index 0bd6219a..3d5a570e 100644
--- a/es_PE/es_PE.go
+++ b/es_PE/es_PE.go
@@ -76,36 +76,24 @@ func (es *es_PE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (es *es_PE) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(es.decimal) + len(es.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(es.decimal) - 1; j >= 0; j-- {
- b = append(b, es.decimal[j])
- }
-
+ b = append(b, es.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(es.group) - 1; j >= 0; j-- {
- b = append(b, es.group[j])
- }
-
+ b = append(b, es.group[0])
count = 1
} else {
count++
@@ -115,11 +103,14 @@ func (es *es_PE) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, es.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/es_PH/es_PH.go b/es_PH/es_PH.go
index d79b6dba..b6da810a 100644
--- a/es_PH/es_PH.go
+++ b/es_PH/es_PH.go
@@ -76,36 +76,24 @@ func (es *es_PH) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (es *es_PH) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(es.decimal) + len(es.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(es.decimal) - 1; j >= 0; j-- {
- b = append(b, es.decimal[j])
- }
-
+ b = append(b, es.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(es.group) - 1; j >= 0; j-- {
- b = append(b, es.group[j])
- }
-
+ b = append(b, es.group[0])
count = 1
} else {
count++
@@ -115,11 +103,14 @@ func (es *es_PH) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, es.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/es_PR/es_PR.go b/es_PR/es_PR.go
index dd84488e..620e07f4 100644
--- a/es_PR/es_PR.go
+++ b/es_PR/es_PR.go
@@ -76,36 +76,24 @@ func (es *es_PR) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (es *es_PR) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(es.decimal) + len(es.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(es.decimal) - 1; j >= 0; j-- {
- b = append(b, es.decimal[j])
- }
-
+ b = append(b, es.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(es.group) - 1; j >= 0; j-- {
- b = append(b, es.group[j])
- }
-
+ b = append(b, es.group[0])
count = 1
} else {
count++
@@ -115,11 +103,14 @@ func (es *es_PR) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, es.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/es_PY/es_PY.go b/es_PY/es_PY.go
index 6fe82eb1..9d5fec9d 100644
--- a/es_PY/es_PY.go
+++ b/es_PY/es_PY.go
@@ -76,36 +76,24 @@ func (es *es_PY) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (es *es_PY) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(es.decimal) + len(es.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(es.decimal) - 1; j >= 0; j-- {
- b = append(b, es.decimal[j])
- }
-
+ b = append(b, es.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(es.group) - 1; j >= 0; j-- {
- b = append(b, es.group[j])
- }
-
+ b = append(b, es.group[0])
count = 1
} else {
count++
@@ -115,11 +103,14 @@ func (es *es_PY) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, es.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/es_SV/es_SV.go b/es_SV/es_SV.go
index 8a81b122..cfd2e186 100644
--- a/es_SV/es_SV.go
+++ b/es_SV/es_SV.go
@@ -76,36 +76,24 @@ func (es *es_SV) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (es *es_SV) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(es.decimal) + len(es.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(es.decimal) - 1; j >= 0; j-- {
- b = append(b, es.decimal[j])
- }
-
+ b = append(b, es.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(es.group) - 1; j >= 0; j-- {
- b = append(b, es.group[j])
- }
-
+ b = append(b, es.group[0])
count = 1
} else {
count++
@@ -115,11 +103,14 @@ func (es *es_SV) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, es.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/es_US/es_US.go b/es_US/es_US.go
index c32937a8..e4827a0f 100644
--- a/es_US/es_US.go
+++ b/es_US/es_US.go
@@ -76,36 +76,24 @@ func (es *es_US) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (es *es_US) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(es.decimal) + len(es.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(es.decimal) - 1; j >= 0; j-- {
- b = append(b, es.decimal[j])
- }
-
+ b = append(b, es.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(es.group) - 1; j >= 0; j-- {
- b = append(b, es.group[j])
- }
-
+ b = append(b, es.group[0])
count = 1
} else {
count++
@@ -115,11 +103,14 @@ func (es *es_US) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, es.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/es_UY/es_UY.go b/es_UY/es_UY.go
index 03f6f23f..4e4c6faf 100644
--- a/es_UY/es_UY.go
+++ b/es_UY/es_UY.go
@@ -76,36 +76,24 @@ func (es *es_UY) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (es *es_UY) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(es.decimal) + len(es.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(es.decimal) - 1; j >= 0; j-- {
- b = append(b, es.decimal[j])
- }
-
+ b = append(b, es.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(es.group) - 1; j >= 0; j-- {
- b = append(b, es.group[j])
- }
-
+ b = append(b, es.group[0])
count = 1
} else {
count++
@@ -115,11 +103,14 @@ func (es *es_UY) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, es.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/es_VE/es_VE.go b/es_VE/es_VE.go
index b9366d9f..3118ecd0 100644
--- a/es_VE/es_VE.go
+++ b/es_VE/es_VE.go
@@ -76,36 +76,24 @@ func (es *es_VE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (es *es_VE) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(es.decimal) + len(es.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(es.decimal) - 1; j >= 0; j-- {
- b = append(b, es.decimal[j])
- }
-
+ b = append(b, es.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(es.group) - 1; j >= 0; j-- {
- b = append(b, es.group[j])
- }
-
+ b = append(b, es.group[0])
count = 1
} else {
count++
@@ -115,11 +103,14 @@ func (es *es_VE) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, es.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/et/et.go b/et/et.go
index 610ec3bd..899a23b7 100644
--- a/et/et.go
+++ b/et/et.go
@@ -77,32 +77,23 @@ func (et *et) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (et *et) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(et.decimal) + len(et.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(et.decimal) - 1; j >= 0; j-- {
- b = append(b, et.decimal[j])
- }
-
+ b = append(b, et.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(et.group) - 1; j >= 0; j-- {
b = append(b, et.group[j])
}
@@ -116,11 +107,16 @@ func (et *et) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(et.minus) - 1; j >= 0; j-- {
+ b = append(b, et.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/et_EE/et_EE.go b/et_EE/et_EE.go
index 3282d251..390fa386 100644
--- a/et_EE/et_EE.go
+++ b/et_EE/et_EE.go
@@ -77,32 +77,23 @@ func (et *et_EE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (et *et_EE) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(et.decimal) + len(et.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(et.decimal) - 1; j >= 0; j-- {
- b = append(b, et.decimal[j])
- }
-
+ b = append(b, et.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(et.group) - 1; j >= 0; j-- {
b = append(b, et.group[j])
}
@@ -116,11 +107,16 @@ func (et *et_EE) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(et.minus) - 1; j >= 0; j-- {
+ b = append(b, et.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/eu/eu.go b/eu/eu.go
index ce2481b6..ccca4516 100644
--- a/eu/eu.go
+++ b/eu/eu.go
@@ -76,36 +76,24 @@ func (eu *eu) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (eu *eu) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(eu.decimal) + len(eu.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(eu.decimal) - 1; j >= 0; j-- {
- b = append(b, eu.decimal[j])
- }
-
+ b = append(b, eu.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(eu.group) - 1; j >= 0; j-- {
- b = append(b, eu.group[j])
- }
-
+ b = append(b, eu.group[0])
count = 1
} else {
count++
@@ -115,11 +103,14 @@ func (eu *eu) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, eu.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/eu_ES/eu_ES.go b/eu_ES/eu_ES.go
index 72ecfcdc..581e9779 100644
--- a/eu_ES/eu_ES.go
+++ b/eu_ES/eu_ES.go
@@ -76,36 +76,24 @@ func (eu *eu_ES) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (eu *eu_ES) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(eu.decimal) + len(eu.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(eu.decimal) - 1; j >= 0; j-- {
- b = append(b, eu.decimal[j])
- }
-
+ b = append(b, eu.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(eu.group) - 1; j >= 0; j-- {
- b = append(b, eu.group[j])
- }
-
+ b = append(b, eu.group[0])
count = 1
} else {
count++
@@ -115,11 +103,14 @@ func (eu *eu_ES) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, eu.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ewo/ewo.go b/ewo/ewo.go
index 131fd775..013d5f76 100644
--- a/ewo/ewo.go
+++ b/ewo/ewo.go
@@ -1,6 +1,7 @@
package ewo
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,32 +69,23 @@ func (ewo *ewo) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (ewo *ewo) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ewo.decimal) + len(ewo.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ewo.decimal) - 1; j >= 0; j-- {
- b = append(b, ewo.decimal[j])
- }
-
+ b = append(b, ewo.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(ewo.group) - 1; j >= 0; j-- {
b = append(b, ewo.group[j])
}
@@ -107,11 +99,16 @@ func (ewo *ewo) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(ewo.minus) - 1; j >= 0; j-- {
+ b = append(b, ewo.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ewo_CM/ewo_CM.go b/ewo_CM/ewo_CM.go
index 8d21f503..9d263090 100644
--- a/ewo_CM/ewo_CM.go
+++ b/ewo_CM/ewo_CM.go
@@ -1,6 +1,7 @@
package ewo_CM
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,32 +69,23 @@ func (ewo *ewo_CM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (ewo *ewo_CM) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ewo.decimal) + len(ewo.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ewo.decimal) - 1; j >= 0; j-- {
- b = append(b, ewo.decimal[j])
- }
-
+ b = append(b, ewo.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(ewo.group) - 1; j >= 0; j-- {
b = append(b, ewo.group[j])
}
@@ -107,11 +99,16 @@ func (ewo *ewo_CM) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(ewo.minus) - 1; j >= 0; j-- {
+ b = append(b, ewo.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fa/fa.go b/fa/fa.go
index 1a1668f7..6fde398c 100644
--- a/fa/fa.go
+++ b/fa/fa.go
@@ -77,19 +77,15 @@ func (fa *fa) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (fa *fa) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fa.decimal) + len(fa.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(fa.decimal) - 1; j >= 0; j-- {
b = append(b, fa.decimal[j])
}
@@ -100,9 +96,7 @@ func (fa *fa) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(fa.group) - 1; j >= 0; j-- {
b = append(b, fa.group[j])
}
@@ -116,11 +110,16 @@ func (fa *fa) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fa.minus) - 1; j >= 0; j-- {
+ b = append(b, fa.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fa_AF/fa_AF.go b/fa_AF/fa_AF.go
index bfa7bd6b..3ab4734e 100644
--- a/fa_AF/fa_AF.go
+++ b/fa_AF/fa_AF.go
@@ -77,19 +77,15 @@ func (fa *fa_AF) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (fa *fa_AF) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fa.decimal) + len(fa.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(fa.decimal) - 1; j >= 0; j-- {
b = append(b, fa.decimal[j])
}
@@ -100,9 +96,7 @@ func (fa *fa_AF) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(fa.group) - 1; j >= 0; j-- {
b = append(b, fa.group[j])
}
@@ -116,11 +110,16 @@ func (fa *fa_AF) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fa.minus) - 1; j >= 0; j-- {
+ b = append(b, fa.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fa_IR/fa_IR.go b/fa_IR/fa_IR.go
index 5d63f6b2..8a990ba9 100644
--- a/fa_IR/fa_IR.go
+++ b/fa_IR/fa_IR.go
@@ -77,19 +77,15 @@ func (fa *fa_IR) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (fa *fa_IR) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fa.decimal) + len(fa.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(fa.decimal) - 1; j >= 0; j-- {
b = append(b, fa.decimal[j])
}
@@ -100,9 +96,7 @@ func (fa *fa_IR) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(fa.group) - 1; j >= 0; j-- {
b = append(b, fa.group[j])
}
@@ -116,11 +110,16 @@ func (fa *fa_IR) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fa.minus) - 1; j >= 0; j-- {
+ b = append(b, fa.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ff/ff.go b/ff/ff.go
index 8828cb16..06f994b9 100644
--- a/ff/ff.go
+++ b/ff/ff.go
@@ -77,8 +77,6 @@ func (ff *ff) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (ff *ff) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/ff_CM/ff_CM.go b/ff_CM/ff_CM.go
index 1bdb0368..c2dab8e9 100644
--- a/ff_CM/ff_CM.go
+++ b/ff_CM/ff_CM.go
@@ -77,8 +77,6 @@ func (ff *ff_CM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ff *ff_CM) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/ff_GN/ff_GN.go b/ff_GN/ff_GN.go
index 2d2e4bc4..c52c59cf 100644
--- a/ff_GN/ff_GN.go
+++ b/ff_GN/ff_GN.go
@@ -77,8 +77,6 @@ func (ff *ff_GN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ff *ff_GN) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/ff_MR/ff_MR.go b/ff_MR/ff_MR.go
index b5c4c393..b97ce017 100644
--- a/ff_MR/ff_MR.go
+++ b/ff_MR/ff_MR.go
@@ -77,8 +77,6 @@ func (ff *ff_MR) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ff *ff_MR) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/ff_SN/ff_SN.go b/ff_SN/ff_SN.go
index 1b49b929..b6f5eb8d 100644
--- a/ff_SN/ff_SN.go
+++ b/ff_SN/ff_SN.go
@@ -77,8 +77,6 @@ func (ff *ff_SN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ff *ff_SN) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/fi/fi.go b/fi/fi.go
index 5daf5eab..0dc1bf46 100644
--- a/fi/fi.go
+++ b/fi/fi.go
@@ -77,32 +77,23 @@ func (fi *fi) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (fi *fi) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fi.decimal) + len(fi.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(fi.decimal) - 1; j >= 0; j-- {
- b = append(b, fi.decimal[j])
- }
-
+ b = append(b, fi.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(fi.group) - 1; j >= 0; j-- {
b = append(b, fi.group[j])
}
@@ -116,11 +107,16 @@ func (fi *fi) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fi.minus) - 1; j >= 0; j-- {
+ b = append(b, fi.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fi_FI/fi_FI.go b/fi_FI/fi_FI.go
index 453d9d28..fa8bfce8 100644
--- a/fi_FI/fi_FI.go
+++ b/fi_FI/fi_FI.go
@@ -77,32 +77,23 @@ func (fi *fi_FI) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (fi *fi_FI) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fi.decimal) + len(fi.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(fi.decimal) - 1; j >= 0; j-- {
- b = append(b, fi.decimal[j])
- }
-
+ b = append(b, fi.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(fi.group) - 1; j >= 0; j-- {
b = append(b, fi.group[j])
}
@@ -116,11 +107,16 @@ func (fi *fi_FI) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fi.minus) - 1; j >= 0; j-- {
+ b = append(b, fi.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fil/fil.go b/fil/fil.go
index 3b60c29b..9b5898dc 100644
--- a/fil/fil.go
+++ b/fil/fil.go
@@ -100,36 +100,24 @@ func (fil *fil) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (fil *fil) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fil.decimal) + len(fil.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(fil.decimal) - 1; j >= 0; j-- {
- b = append(b, fil.decimal[j])
- }
-
+ b = append(b, fil.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(fil.group) - 1; j >= 0; j-- {
- b = append(b, fil.group[j])
- }
-
+ b = append(b, fil.group[0])
count = 1
} else {
count++
@@ -139,11 +127,14 @@ func (fil *fil) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, fil.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fil_PH/fil_PH.go b/fil_PH/fil_PH.go
index 89e06d4e..ba6b85b9 100644
--- a/fil_PH/fil_PH.go
+++ b/fil_PH/fil_PH.go
@@ -100,36 +100,24 @@ func (fil *fil_PH) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (fil *fil_PH) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fil.decimal) + len(fil.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(fil.decimal) - 1; j >= 0; j-- {
- b = append(b, fil.decimal[j])
- }
-
+ b = append(b, fil.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(fil.group) - 1; j >= 0; j-- {
- b = append(b, fil.group[j])
- }
-
+ b = append(b, fil.group[0])
count = 1
} else {
count++
@@ -139,11 +127,14 @@ func (fil *fil_PH) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, fil.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fo/fo.go b/fo/fo.go
index 3184697b..0d132db4 100644
--- a/fo/fo.go
+++ b/fo/fo.go
@@ -76,36 +76,24 @@ func (fo *fo) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (fo *fo) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fo.decimal) + len(fo.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(fo.decimal) - 1; j >= 0; j-- {
- b = append(b, fo.decimal[j])
- }
-
+ b = append(b, fo.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(fo.group) - 1; j >= 0; j-- {
- b = append(b, fo.group[j])
- }
-
+ b = append(b, fo.group[0])
count = 1
} else {
count++
@@ -115,11 +103,16 @@ func (fo *fo) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fo.minus) - 1; j >= 0; j-- {
+ b = append(b, fo.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fo_DK/fo_DK.go b/fo_DK/fo_DK.go
index 4eaab93b..48d06fc2 100644
--- a/fo_DK/fo_DK.go
+++ b/fo_DK/fo_DK.go
@@ -76,36 +76,24 @@ func (fo *fo_DK) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (fo *fo_DK) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fo.decimal) + len(fo.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(fo.decimal) - 1; j >= 0; j-- {
- b = append(b, fo.decimal[j])
- }
-
+ b = append(b, fo.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(fo.group) - 1; j >= 0; j-- {
- b = append(b, fo.group[j])
- }
-
+ b = append(b, fo.group[0])
count = 1
} else {
count++
@@ -115,11 +103,16 @@ func (fo *fo_DK) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fo.minus) - 1; j >= 0; j-- {
+ b = append(b, fo.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fo_FO/fo_FO.go b/fo_FO/fo_FO.go
index 5fcf1960..08cdee64 100644
--- a/fo_FO/fo_FO.go
+++ b/fo_FO/fo_FO.go
@@ -76,36 +76,24 @@ func (fo *fo_FO) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (fo *fo_FO) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fo.decimal) + len(fo.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(fo.decimal) - 1; j >= 0; j-- {
- b = append(b, fo.decimal[j])
- }
-
+ b = append(b, fo.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(fo.group) - 1; j >= 0; j-- {
- b = append(b, fo.group[j])
- }
-
+ b = append(b, fo.group[0])
count = 1
} else {
count++
@@ -115,11 +103,16 @@ func (fo *fo_FO) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fo.minus) - 1; j >= 0; j-- {
+ b = append(b, fo.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fr/fr.go b/fr/fr.go
index 7e0f7533..ac2200c1 100644
--- a/fr/fr.go
+++ b/fr/fr.go
@@ -95,19 +95,15 @@ func (fr *fr) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (fr *fr) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fr.decimal) + len(fr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(fr.decimal) - 1; j >= 0; j-- {
b = append(b, fr.decimal[j])
}
@@ -118,9 +114,7 @@ func (fr *fr) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(fr.group) - 1; j >= 0; j-- {
b = append(b, fr.group[j])
}
@@ -134,11 +128,16 @@ func (fr *fr) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fr.minus) - 1; j >= 0; j-- {
+ b = append(b, fr.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fr_BE/fr_BE.go b/fr_BE/fr_BE.go
index a87664db..87210ccb 100644
--- a/fr_BE/fr_BE.go
+++ b/fr_BE/fr_BE.go
@@ -95,19 +95,15 @@ func (fr *fr_BE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (fr *fr_BE) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fr.decimal) + len(fr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(fr.decimal) - 1; j >= 0; j-- {
b = append(b, fr.decimal[j])
}
@@ -118,13 +114,8 @@ func (fr *fr_BE) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
- for j := len(fr.group) - 1; j >= 0; j-- {
- b = append(b, fr.group[j])
- }
-
+ b = append(b, fr.group[0])
count = 1
} else {
count++
@@ -134,11 +125,16 @@ func (fr *fr_BE) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fr.minus) - 1; j >= 0; j-- {
+ b = append(b, fr.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fr_BF/fr_BF.go b/fr_BF/fr_BF.go
index d055a306..69b14fe2 100644
--- a/fr_BF/fr_BF.go
+++ b/fr_BF/fr_BF.go
@@ -95,19 +95,15 @@ func (fr *fr_BF) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (fr *fr_BF) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fr.decimal) + len(fr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(fr.decimal) - 1; j >= 0; j-- {
b = append(b, fr.decimal[j])
}
@@ -118,9 +114,7 @@ func (fr *fr_BF) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(fr.group) - 1; j >= 0; j-- {
b = append(b, fr.group[j])
}
@@ -134,11 +128,16 @@ func (fr *fr_BF) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fr.minus) - 1; j >= 0; j-- {
+ b = append(b, fr.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fr_BI/fr_BI.go b/fr_BI/fr_BI.go
index e6d4a1e9..9a36c366 100644
--- a/fr_BI/fr_BI.go
+++ b/fr_BI/fr_BI.go
@@ -95,19 +95,15 @@ func (fr *fr_BI) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (fr *fr_BI) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fr.decimal) + len(fr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(fr.decimal) - 1; j >= 0; j-- {
b = append(b, fr.decimal[j])
}
@@ -118,9 +114,7 @@ func (fr *fr_BI) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(fr.group) - 1; j >= 0; j-- {
b = append(b, fr.group[j])
}
@@ -134,11 +128,16 @@ func (fr *fr_BI) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fr.minus) - 1; j >= 0; j-- {
+ b = append(b, fr.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fr_BJ/fr_BJ.go b/fr_BJ/fr_BJ.go
index 04a23fd3..bf337938 100644
--- a/fr_BJ/fr_BJ.go
+++ b/fr_BJ/fr_BJ.go
@@ -95,19 +95,15 @@ func (fr *fr_BJ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (fr *fr_BJ) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fr.decimal) + len(fr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(fr.decimal) - 1; j >= 0; j-- {
b = append(b, fr.decimal[j])
}
@@ -118,9 +114,7 @@ func (fr *fr_BJ) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(fr.group) - 1; j >= 0; j-- {
b = append(b, fr.group[j])
}
@@ -134,11 +128,16 @@ func (fr *fr_BJ) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fr.minus) - 1; j >= 0; j-- {
+ b = append(b, fr.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fr_BL/fr_BL.go b/fr_BL/fr_BL.go
index 0b523849..cac5fd5b 100644
--- a/fr_BL/fr_BL.go
+++ b/fr_BL/fr_BL.go
@@ -95,19 +95,15 @@ func (fr *fr_BL) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (fr *fr_BL) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fr.decimal) + len(fr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(fr.decimal) - 1; j >= 0; j-- {
b = append(b, fr.decimal[j])
}
@@ -118,9 +114,7 @@ func (fr *fr_BL) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(fr.group) - 1; j >= 0; j-- {
b = append(b, fr.group[j])
}
@@ -134,11 +128,16 @@ func (fr *fr_BL) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fr.minus) - 1; j >= 0; j-- {
+ b = append(b, fr.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fr_CA/fr_CA.go b/fr_CA/fr_CA.go
index b381bde0..f2a00932 100644
--- a/fr_CA/fr_CA.go
+++ b/fr_CA/fr_CA.go
@@ -95,19 +95,15 @@ func (fr *fr_CA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (fr *fr_CA) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fr.decimal) + len(fr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(fr.decimal) - 1; j >= 0; j-- {
b = append(b, fr.decimal[j])
}
@@ -118,9 +114,7 @@ func (fr *fr_CA) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(fr.group) - 1; j >= 0; j-- {
b = append(b, fr.group[j])
}
@@ -134,11 +128,16 @@ func (fr *fr_CA) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fr.minus) - 1; j >= 0; j-- {
+ b = append(b, fr.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fr_CD/fr_CD.go b/fr_CD/fr_CD.go
index 3ea94169..ae83cc58 100644
--- a/fr_CD/fr_CD.go
+++ b/fr_CD/fr_CD.go
@@ -95,19 +95,15 @@ func (fr *fr_CD) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (fr *fr_CD) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fr.decimal) + len(fr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(fr.decimal) - 1; j >= 0; j-- {
b = append(b, fr.decimal[j])
}
@@ -118,9 +114,7 @@ func (fr *fr_CD) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(fr.group) - 1; j >= 0; j-- {
b = append(b, fr.group[j])
}
@@ -134,11 +128,16 @@ func (fr *fr_CD) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fr.minus) - 1; j >= 0; j-- {
+ b = append(b, fr.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fr_CF/fr_CF.go b/fr_CF/fr_CF.go
index db5738a1..ab19f504 100644
--- a/fr_CF/fr_CF.go
+++ b/fr_CF/fr_CF.go
@@ -95,19 +95,15 @@ func (fr *fr_CF) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (fr *fr_CF) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fr.decimal) + len(fr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(fr.decimal) - 1; j >= 0; j-- {
b = append(b, fr.decimal[j])
}
@@ -118,9 +114,7 @@ func (fr *fr_CF) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(fr.group) - 1; j >= 0; j-- {
b = append(b, fr.group[j])
}
@@ -134,11 +128,16 @@ func (fr *fr_CF) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fr.minus) - 1; j >= 0; j-- {
+ b = append(b, fr.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fr_CG/fr_CG.go b/fr_CG/fr_CG.go
index 47092886..61e3bbd4 100644
--- a/fr_CG/fr_CG.go
+++ b/fr_CG/fr_CG.go
@@ -95,19 +95,15 @@ func (fr *fr_CG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (fr *fr_CG) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fr.decimal) + len(fr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(fr.decimal) - 1; j >= 0; j-- {
b = append(b, fr.decimal[j])
}
@@ -118,9 +114,7 @@ func (fr *fr_CG) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(fr.group) - 1; j >= 0; j-- {
b = append(b, fr.group[j])
}
@@ -134,11 +128,16 @@ func (fr *fr_CG) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fr.minus) - 1; j >= 0; j-- {
+ b = append(b, fr.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fr_CH/fr_CH.go b/fr_CH/fr_CH.go
index 74ea9fe4..accc0cdd 100644
--- a/fr_CH/fr_CH.go
+++ b/fr_CH/fr_CH.go
@@ -95,32 +95,23 @@ func (fr *fr_CH) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (fr *fr_CH) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fr.decimal) + len(fr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(fr.decimal) - 1; j >= 0; j-- {
- b = append(b, fr.decimal[j])
- }
-
+ b = append(b, fr.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(fr.group) - 1; j >= 0; j-- {
b = append(b, fr.group[j])
}
@@ -134,11 +125,16 @@ func (fr *fr_CH) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fr.minus) - 1; j >= 0; j-- {
+ b = append(b, fr.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fr_CI/fr_CI.go b/fr_CI/fr_CI.go
index 6434410e..e396001b 100644
--- a/fr_CI/fr_CI.go
+++ b/fr_CI/fr_CI.go
@@ -95,19 +95,15 @@ func (fr *fr_CI) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (fr *fr_CI) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fr.decimal) + len(fr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(fr.decimal) - 1; j >= 0; j-- {
b = append(b, fr.decimal[j])
}
@@ -118,9 +114,7 @@ func (fr *fr_CI) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(fr.group) - 1; j >= 0; j-- {
b = append(b, fr.group[j])
}
@@ -134,11 +128,16 @@ func (fr *fr_CI) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fr.minus) - 1; j >= 0; j-- {
+ b = append(b, fr.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fr_CM/fr_CM.go b/fr_CM/fr_CM.go
index 44d1136d..fc9b1422 100644
--- a/fr_CM/fr_CM.go
+++ b/fr_CM/fr_CM.go
@@ -95,19 +95,15 @@ func (fr *fr_CM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (fr *fr_CM) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fr.decimal) + len(fr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(fr.decimal) - 1; j >= 0; j-- {
b = append(b, fr.decimal[j])
}
@@ -118,9 +114,7 @@ func (fr *fr_CM) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(fr.group) - 1; j >= 0; j-- {
b = append(b, fr.group[j])
}
@@ -134,11 +128,16 @@ func (fr *fr_CM) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fr.minus) - 1; j >= 0; j-- {
+ b = append(b, fr.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fr_DJ/fr_DJ.go b/fr_DJ/fr_DJ.go
index f2ea67f3..c1124e9a 100644
--- a/fr_DJ/fr_DJ.go
+++ b/fr_DJ/fr_DJ.go
@@ -95,19 +95,15 @@ func (fr *fr_DJ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (fr *fr_DJ) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fr.decimal) + len(fr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(fr.decimal) - 1; j >= 0; j-- {
b = append(b, fr.decimal[j])
}
@@ -118,9 +114,7 @@ func (fr *fr_DJ) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(fr.group) - 1; j >= 0; j-- {
b = append(b, fr.group[j])
}
@@ -134,11 +128,16 @@ func (fr *fr_DJ) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fr.minus) - 1; j >= 0; j-- {
+ b = append(b, fr.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fr_DZ/fr_DZ.go b/fr_DZ/fr_DZ.go
index c1aa38ab..84314e20 100644
--- a/fr_DZ/fr_DZ.go
+++ b/fr_DZ/fr_DZ.go
@@ -95,19 +95,15 @@ func (fr *fr_DZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (fr *fr_DZ) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fr.decimal) + len(fr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(fr.decimal) - 1; j >= 0; j-- {
b = append(b, fr.decimal[j])
}
@@ -118,9 +114,7 @@ func (fr *fr_DZ) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(fr.group) - 1; j >= 0; j-- {
b = append(b, fr.group[j])
}
@@ -134,11 +128,16 @@ func (fr *fr_DZ) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fr.minus) - 1; j >= 0; j-- {
+ b = append(b, fr.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fr_FR/fr_FR.go b/fr_FR/fr_FR.go
index f986d0ba..917500b9 100644
--- a/fr_FR/fr_FR.go
+++ b/fr_FR/fr_FR.go
@@ -95,19 +95,15 @@ func (fr *fr_FR) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (fr *fr_FR) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fr.decimal) + len(fr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(fr.decimal) - 1; j >= 0; j-- {
b = append(b, fr.decimal[j])
}
@@ -118,9 +114,7 @@ func (fr *fr_FR) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(fr.group) - 1; j >= 0; j-- {
b = append(b, fr.group[j])
}
@@ -134,11 +128,16 @@ func (fr *fr_FR) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fr.minus) - 1; j >= 0; j-- {
+ b = append(b, fr.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fr_GA/fr_GA.go b/fr_GA/fr_GA.go
index b0fed4af..aa41211f 100644
--- a/fr_GA/fr_GA.go
+++ b/fr_GA/fr_GA.go
@@ -95,19 +95,15 @@ func (fr *fr_GA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (fr *fr_GA) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fr.decimal) + len(fr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(fr.decimal) - 1; j >= 0; j-- {
b = append(b, fr.decimal[j])
}
@@ -118,9 +114,7 @@ func (fr *fr_GA) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(fr.group) - 1; j >= 0; j-- {
b = append(b, fr.group[j])
}
@@ -134,11 +128,16 @@ func (fr *fr_GA) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fr.minus) - 1; j >= 0; j-- {
+ b = append(b, fr.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fr_GF/fr_GF.go b/fr_GF/fr_GF.go
index d89b1584..c9477a0a 100644
--- a/fr_GF/fr_GF.go
+++ b/fr_GF/fr_GF.go
@@ -95,19 +95,15 @@ func (fr *fr_GF) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (fr *fr_GF) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fr.decimal) + len(fr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(fr.decimal) - 1; j >= 0; j-- {
b = append(b, fr.decimal[j])
}
@@ -118,9 +114,7 @@ func (fr *fr_GF) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(fr.group) - 1; j >= 0; j-- {
b = append(b, fr.group[j])
}
@@ -134,11 +128,16 @@ func (fr *fr_GF) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fr.minus) - 1; j >= 0; j-- {
+ b = append(b, fr.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fr_GN/fr_GN.go b/fr_GN/fr_GN.go
index 44e83fa3..d0e2ac01 100644
--- a/fr_GN/fr_GN.go
+++ b/fr_GN/fr_GN.go
@@ -95,19 +95,15 @@ func (fr *fr_GN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (fr *fr_GN) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fr.decimal) + len(fr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(fr.decimal) - 1; j >= 0; j-- {
b = append(b, fr.decimal[j])
}
@@ -118,9 +114,7 @@ func (fr *fr_GN) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(fr.group) - 1; j >= 0; j-- {
b = append(b, fr.group[j])
}
@@ -134,11 +128,16 @@ func (fr *fr_GN) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fr.minus) - 1; j >= 0; j-- {
+ b = append(b, fr.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fr_GP/fr_GP.go b/fr_GP/fr_GP.go
index caa6fb63..2c64c554 100644
--- a/fr_GP/fr_GP.go
+++ b/fr_GP/fr_GP.go
@@ -95,19 +95,15 @@ func (fr *fr_GP) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (fr *fr_GP) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fr.decimal) + len(fr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(fr.decimal) - 1; j >= 0; j-- {
b = append(b, fr.decimal[j])
}
@@ -118,9 +114,7 @@ func (fr *fr_GP) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(fr.group) - 1; j >= 0; j-- {
b = append(b, fr.group[j])
}
@@ -134,11 +128,16 @@ func (fr *fr_GP) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fr.minus) - 1; j >= 0; j-- {
+ b = append(b, fr.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fr_GQ/fr_GQ.go b/fr_GQ/fr_GQ.go
index c174e797..4f782568 100644
--- a/fr_GQ/fr_GQ.go
+++ b/fr_GQ/fr_GQ.go
@@ -95,19 +95,15 @@ func (fr *fr_GQ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (fr *fr_GQ) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fr.decimal) + len(fr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(fr.decimal) - 1; j >= 0; j-- {
b = append(b, fr.decimal[j])
}
@@ -118,9 +114,7 @@ func (fr *fr_GQ) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(fr.group) - 1; j >= 0; j-- {
b = append(b, fr.group[j])
}
@@ -134,11 +128,16 @@ func (fr *fr_GQ) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fr.minus) - 1; j >= 0; j-- {
+ b = append(b, fr.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fr_HT/fr_HT.go b/fr_HT/fr_HT.go
index a2ecd2aa..9deac34c 100644
--- a/fr_HT/fr_HT.go
+++ b/fr_HT/fr_HT.go
@@ -95,19 +95,15 @@ func (fr *fr_HT) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (fr *fr_HT) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fr.decimal) + len(fr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(fr.decimal) - 1; j >= 0; j-- {
b = append(b, fr.decimal[j])
}
@@ -118,9 +114,7 @@ func (fr *fr_HT) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(fr.group) - 1; j >= 0; j-- {
b = append(b, fr.group[j])
}
@@ -134,11 +128,16 @@ func (fr *fr_HT) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fr.minus) - 1; j >= 0; j-- {
+ b = append(b, fr.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fr_KM/fr_KM.go b/fr_KM/fr_KM.go
index 6e4fb6a8..1c51dc21 100644
--- a/fr_KM/fr_KM.go
+++ b/fr_KM/fr_KM.go
@@ -95,19 +95,15 @@ func (fr *fr_KM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (fr *fr_KM) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fr.decimal) + len(fr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(fr.decimal) - 1; j >= 0; j-- {
b = append(b, fr.decimal[j])
}
@@ -118,9 +114,7 @@ func (fr *fr_KM) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(fr.group) - 1; j >= 0; j-- {
b = append(b, fr.group[j])
}
@@ -134,11 +128,16 @@ func (fr *fr_KM) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fr.minus) - 1; j >= 0; j-- {
+ b = append(b, fr.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fr_LU/fr_LU.go b/fr_LU/fr_LU.go
index 12926a7d..5086c161 100644
--- a/fr_LU/fr_LU.go
+++ b/fr_LU/fr_LU.go
@@ -95,19 +95,15 @@ func (fr *fr_LU) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (fr *fr_LU) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fr.decimal) + len(fr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(fr.decimal) - 1; j >= 0; j-- {
b = append(b, fr.decimal[j])
}
@@ -118,13 +114,8 @@ func (fr *fr_LU) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
- for j := len(fr.group) - 1; j >= 0; j-- {
- b = append(b, fr.group[j])
- }
-
+ b = append(b, fr.group[0])
count = 1
} else {
count++
@@ -134,11 +125,16 @@ func (fr *fr_LU) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fr.minus) - 1; j >= 0; j-- {
+ b = append(b, fr.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fr_MA/fr_MA.go b/fr_MA/fr_MA.go
index e15c04ae..244535ec 100644
--- a/fr_MA/fr_MA.go
+++ b/fr_MA/fr_MA.go
@@ -95,19 +95,15 @@ func (fr *fr_MA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (fr *fr_MA) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fr.decimal) + len(fr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(fr.decimal) - 1; j >= 0; j-- {
b = append(b, fr.decimal[j])
}
@@ -118,13 +114,8 @@ func (fr *fr_MA) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
- for j := len(fr.group) - 1; j >= 0; j-- {
- b = append(b, fr.group[j])
- }
-
+ b = append(b, fr.group[0])
count = 1
} else {
count++
@@ -134,11 +125,16 @@ func (fr *fr_MA) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fr.minus) - 1; j >= 0; j-- {
+ b = append(b, fr.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fr_MC/fr_MC.go b/fr_MC/fr_MC.go
index e9950815..a3c7de9b 100644
--- a/fr_MC/fr_MC.go
+++ b/fr_MC/fr_MC.go
@@ -95,19 +95,15 @@ func (fr *fr_MC) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (fr *fr_MC) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fr.decimal) + len(fr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(fr.decimal) - 1; j >= 0; j-- {
b = append(b, fr.decimal[j])
}
@@ -118,9 +114,7 @@ func (fr *fr_MC) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(fr.group) - 1; j >= 0; j-- {
b = append(b, fr.group[j])
}
@@ -134,11 +128,16 @@ func (fr *fr_MC) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fr.minus) - 1; j >= 0; j-- {
+ b = append(b, fr.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fr_MF/fr_MF.go b/fr_MF/fr_MF.go
index 5ce8df94..0c25e9e5 100644
--- a/fr_MF/fr_MF.go
+++ b/fr_MF/fr_MF.go
@@ -95,19 +95,15 @@ func (fr *fr_MF) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (fr *fr_MF) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fr.decimal) + len(fr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(fr.decimal) - 1; j >= 0; j-- {
b = append(b, fr.decimal[j])
}
@@ -118,9 +114,7 @@ func (fr *fr_MF) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(fr.group) - 1; j >= 0; j-- {
b = append(b, fr.group[j])
}
@@ -134,11 +128,16 @@ func (fr *fr_MF) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fr.minus) - 1; j >= 0; j-- {
+ b = append(b, fr.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fr_MG/fr_MG.go b/fr_MG/fr_MG.go
index 1681e0ee..ec819be5 100644
--- a/fr_MG/fr_MG.go
+++ b/fr_MG/fr_MG.go
@@ -95,19 +95,15 @@ func (fr *fr_MG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (fr *fr_MG) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fr.decimal) + len(fr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(fr.decimal) - 1; j >= 0; j-- {
b = append(b, fr.decimal[j])
}
@@ -118,9 +114,7 @@ func (fr *fr_MG) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(fr.group) - 1; j >= 0; j-- {
b = append(b, fr.group[j])
}
@@ -134,11 +128,16 @@ func (fr *fr_MG) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fr.minus) - 1; j >= 0; j-- {
+ b = append(b, fr.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fr_ML/fr_ML.go b/fr_ML/fr_ML.go
index 43d4ba6c..1ba23c6f 100644
--- a/fr_ML/fr_ML.go
+++ b/fr_ML/fr_ML.go
@@ -95,19 +95,15 @@ func (fr *fr_ML) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (fr *fr_ML) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fr.decimal) + len(fr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(fr.decimal) - 1; j >= 0; j-- {
b = append(b, fr.decimal[j])
}
@@ -118,9 +114,7 @@ func (fr *fr_ML) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(fr.group) - 1; j >= 0; j-- {
b = append(b, fr.group[j])
}
@@ -134,11 +128,16 @@ func (fr *fr_ML) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fr.minus) - 1; j >= 0; j-- {
+ b = append(b, fr.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fr_MQ/fr_MQ.go b/fr_MQ/fr_MQ.go
index 8489b502..9a7aceeb 100644
--- a/fr_MQ/fr_MQ.go
+++ b/fr_MQ/fr_MQ.go
@@ -95,19 +95,15 @@ func (fr *fr_MQ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (fr *fr_MQ) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fr.decimal) + len(fr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(fr.decimal) - 1; j >= 0; j-- {
b = append(b, fr.decimal[j])
}
@@ -118,9 +114,7 @@ func (fr *fr_MQ) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(fr.group) - 1; j >= 0; j-- {
b = append(b, fr.group[j])
}
@@ -134,11 +128,16 @@ func (fr *fr_MQ) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fr.minus) - 1; j >= 0; j-- {
+ b = append(b, fr.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fr_MR/fr_MR.go b/fr_MR/fr_MR.go
index fc7d6297..441cfd87 100644
--- a/fr_MR/fr_MR.go
+++ b/fr_MR/fr_MR.go
@@ -95,19 +95,15 @@ func (fr *fr_MR) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (fr *fr_MR) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fr.decimal) + len(fr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(fr.decimal) - 1; j >= 0; j-- {
b = append(b, fr.decimal[j])
}
@@ -118,9 +114,7 @@ func (fr *fr_MR) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(fr.group) - 1; j >= 0; j-- {
b = append(b, fr.group[j])
}
@@ -134,11 +128,16 @@ func (fr *fr_MR) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fr.minus) - 1; j >= 0; j-- {
+ b = append(b, fr.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fr_MU/fr_MU.go b/fr_MU/fr_MU.go
index 8a8dd33e..15c091ba 100644
--- a/fr_MU/fr_MU.go
+++ b/fr_MU/fr_MU.go
@@ -95,19 +95,15 @@ func (fr *fr_MU) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (fr *fr_MU) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fr.decimal) + len(fr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(fr.decimal) - 1; j >= 0; j-- {
b = append(b, fr.decimal[j])
}
@@ -118,9 +114,7 @@ func (fr *fr_MU) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(fr.group) - 1; j >= 0; j-- {
b = append(b, fr.group[j])
}
@@ -134,11 +128,16 @@ func (fr *fr_MU) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fr.minus) - 1; j >= 0; j-- {
+ b = append(b, fr.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fr_NC/fr_NC.go b/fr_NC/fr_NC.go
index ee49137c..7055b90b 100644
--- a/fr_NC/fr_NC.go
+++ b/fr_NC/fr_NC.go
@@ -95,19 +95,15 @@ func (fr *fr_NC) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (fr *fr_NC) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fr.decimal) + len(fr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(fr.decimal) - 1; j >= 0; j-- {
b = append(b, fr.decimal[j])
}
@@ -118,9 +114,7 @@ func (fr *fr_NC) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(fr.group) - 1; j >= 0; j-- {
b = append(b, fr.group[j])
}
@@ -134,11 +128,16 @@ func (fr *fr_NC) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fr.minus) - 1; j >= 0; j-- {
+ b = append(b, fr.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fr_NE/fr_NE.go b/fr_NE/fr_NE.go
index 3e18b4d7..9709d4c7 100644
--- a/fr_NE/fr_NE.go
+++ b/fr_NE/fr_NE.go
@@ -95,19 +95,15 @@ func (fr *fr_NE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (fr *fr_NE) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fr.decimal) + len(fr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(fr.decimal) - 1; j >= 0; j-- {
b = append(b, fr.decimal[j])
}
@@ -118,9 +114,7 @@ func (fr *fr_NE) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(fr.group) - 1; j >= 0; j-- {
b = append(b, fr.group[j])
}
@@ -134,11 +128,16 @@ func (fr *fr_NE) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fr.minus) - 1; j >= 0; j-- {
+ b = append(b, fr.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fr_PF/fr_PF.go b/fr_PF/fr_PF.go
index 70651115..9c9c60ac 100644
--- a/fr_PF/fr_PF.go
+++ b/fr_PF/fr_PF.go
@@ -95,19 +95,15 @@ func (fr *fr_PF) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (fr *fr_PF) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fr.decimal) + len(fr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(fr.decimal) - 1; j >= 0; j-- {
b = append(b, fr.decimal[j])
}
@@ -118,9 +114,7 @@ func (fr *fr_PF) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(fr.group) - 1; j >= 0; j-- {
b = append(b, fr.group[j])
}
@@ -134,11 +128,16 @@ func (fr *fr_PF) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fr.minus) - 1; j >= 0; j-- {
+ b = append(b, fr.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fr_PM/fr_PM.go b/fr_PM/fr_PM.go
index c8fff0c7..71ffd4a1 100644
--- a/fr_PM/fr_PM.go
+++ b/fr_PM/fr_PM.go
@@ -95,19 +95,15 @@ func (fr *fr_PM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (fr *fr_PM) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fr.decimal) + len(fr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(fr.decimal) - 1; j >= 0; j-- {
b = append(b, fr.decimal[j])
}
@@ -118,9 +114,7 @@ func (fr *fr_PM) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(fr.group) - 1; j >= 0; j-- {
b = append(b, fr.group[j])
}
@@ -134,11 +128,16 @@ func (fr *fr_PM) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fr.minus) - 1; j >= 0; j-- {
+ b = append(b, fr.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fr_RE/fr_RE.go b/fr_RE/fr_RE.go
index 14e5ec81..76d438e4 100644
--- a/fr_RE/fr_RE.go
+++ b/fr_RE/fr_RE.go
@@ -95,19 +95,15 @@ func (fr *fr_RE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (fr *fr_RE) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fr.decimal) + len(fr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(fr.decimal) - 1; j >= 0; j-- {
b = append(b, fr.decimal[j])
}
@@ -118,9 +114,7 @@ func (fr *fr_RE) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(fr.group) - 1; j >= 0; j-- {
b = append(b, fr.group[j])
}
@@ -134,11 +128,16 @@ func (fr *fr_RE) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fr.minus) - 1; j >= 0; j-- {
+ b = append(b, fr.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fr_RW/fr_RW.go b/fr_RW/fr_RW.go
index 70b225f0..8a8a8d94 100644
--- a/fr_RW/fr_RW.go
+++ b/fr_RW/fr_RW.go
@@ -95,19 +95,15 @@ func (fr *fr_RW) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (fr *fr_RW) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fr.decimal) + len(fr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(fr.decimal) - 1; j >= 0; j-- {
b = append(b, fr.decimal[j])
}
@@ -118,9 +114,7 @@ func (fr *fr_RW) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(fr.group) - 1; j >= 0; j-- {
b = append(b, fr.group[j])
}
@@ -134,11 +128,16 @@ func (fr *fr_RW) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fr.minus) - 1; j >= 0; j-- {
+ b = append(b, fr.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fr_SC/fr_SC.go b/fr_SC/fr_SC.go
index 57cc8367..f76475fa 100644
--- a/fr_SC/fr_SC.go
+++ b/fr_SC/fr_SC.go
@@ -95,19 +95,15 @@ func (fr *fr_SC) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (fr *fr_SC) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fr.decimal) + len(fr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(fr.decimal) - 1; j >= 0; j-- {
b = append(b, fr.decimal[j])
}
@@ -118,9 +114,7 @@ func (fr *fr_SC) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(fr.group) - 1; j >= 0; j-- {
b = append(b, fr.group[j])
}
@@ -134,11 +128,16 @@ func (fr *fr_SC) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fr.minus) - 1; j >= 0; j-- {
+ b = append(b, fr.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fr_SN/fr_SN.go b/fr_SN/fr_SN.go
index e0c4f959..5172c257 100644
--- a/fr_SN/fr_SN.go
+++ b/fr_SN/fr_SN.go
@@ -95,19 +95,15 @@ func (fr *fr_SN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (fr *fr_SN) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fr.decimal) + len(fr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(fr.decimal) - 1; j >= 0; j-- {
b = append(b, fr.decimal[j])
}
@@ -118,9 +114,7 @@ func (fr *fr_SN) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(fr.group) - 1; j >= 0; j-- {
b = append(b, fr.group[j])
}
@@ -134,11 +128,16 @@ func (fr *fr_SN) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fr.minus) - 1; j >= 0; j-- {
+ b = append(b, fr.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fr_SY/fr_SY.go b/fr_SY/fr_SY.go
index 70b8b3e7..1cb6e52d 100644
--- a/fr_SY/fr_SY.go
+++ b/fr_SY/fr_SY.go
@@ -95,19 +95,15 @@ func (fr *fr_SY) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (fr *fr_SY) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fr.decimal) + len(fr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(fr.decimal) - 1; j >= 0; j-- {
b = append(b, fr.decimal[j])
}
@@ -118,9 +114,7 @@ func (fr *fr_SY) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(fr.group) - 1; j >= 0; j-- {
b = append(b, fr.group[j])
}
@@ -134,11 +128,16 @@ func (fr *fr_SY) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fr.minus) - 1; j >= 0; j-- {
+ b = append(b, fr.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fr_TD/fr_TD.go b/fr_TD/fr_TD.go
index ec3f2f95..6a2c032a 100644
--- a/fr_TD/fr_TD.go
+++ b/fr_TD/fr_TD.go
@@ -95,19 +95,15 @@ func (fr *fr_TD) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (fr *fr_TD) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fr.decimal) + len(fr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(fr.decimal) - 1; j >= 0; j-- {
b = append(b, fr.decimal[j])
}
@@ -118,9 +114,7 @@ func (fr *fr_TD) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(fr.group) - 1; j >= 0; j-- {
b = append(b, fr.group[j])
}
@@ -134,11 +128,16 @@ func (fr *fr_TD) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fr.minus) - 1; j >= 0; j-- {
+ b = append(b, fr.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fr_TG/fr_TG.go b/fr_TG/fr_TG.go
index c8f85387..f08e9ed4 100644
--- a/fr_TG/fr_TG.go
+++ b/fr_TG/fr_TG.go
@@ -95,19 +95,15 @@ func (fr *fr_TG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (fr *fr_TG) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fr.decimal) + len(fr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(fr.decimal) - 1; j >= 0; j-- {
b = append(b, fr.decimal[j])
}
@@ -118,9 +114,7 @@ func (fr *fr_TG) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(fr.group) - 1; j >= 0; j-- {
b = append(b, fr.group[j])
}
@@ -134,11 +128,16 @@ func (fr *fr_TG) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fr.minus) - 1; j >= 0; j-- {
+ b = append(b, fr.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fr_TN/fr_TN.go b/fr_TN/fr_TN.go
index ee32cfed..ebe58795 100644
--- a/fr_TN/fr_TN.go
+++ b/fr_TN/fr_TN.go
@@ -95,19 +95,15 @@ func (fr *fr_TN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (fr *fr_TN) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fr.decimal) + len(fr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(fr.decimal) - 1; j >= 0; j-- {
b = append(b, fr.decimal[j])
}
@@ -118,9 +114,7 @@ func (fr *fr_TN) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(fr.group) - 1; j >= 0; j-- {
b = append(b, fr.group[j])
}
@@ -134,11 +128,16 @@ func (fr *fr_TN) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fr.minus) - 1; j >= 0; j-- {
+ b = append(b, fr.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fr_VU/fr_VU.go b/fr_VU/fr_VU.go
index 2aa21e5b..01a7e8c7 100644
--- a/fr_VU/fr_VU.go
+++ b/fr_VU/fr_VU.go
@@ -95,19 +95,15 @@ func (fr *fr_VU) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (fr *fr_VU) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fr.decimal) + len(fr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(fr.decimal) - 1; j >= 0; j-- {
b = append(b, fr.decimal[j])
}
@@ -118,9 +114,7 @@ func (fr *fr_VU) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(fr.group) - 1; j >= 0; j-- {
b = append(b, fr.group[j])
}
@@ -134,11 +128,16 @@ func (fr *fr_VU) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fr.minus) - 1; j >= 0; j-- {
+ b = append(b, fr.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fr_WF/fr_WF.go b/fr_WF/fr_WF.go
index 9c972eff..c77be043 100644
--- a/fr_WF/fr_WF.go
+++ b/fr_WF/fr_WF.go
@@ -95,19 +95,15 @@ func (fr *fr_WF) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (fr *fr_WF) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fr.decimal) + len(fr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(fr.decimal) - 1; j >= 0; j-- {
b = append(b, fr.decimal[j])
}
@@ -118,9 +114,7 @@ func (fr *fr_WF) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(fr.group) - 1; j >= 0; j-- {
b = append(b, fr.group[j])
}
@@ -134,11 +128,16 @@ func (fr *fr_WF) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fr.minus) - 1; j >= 0; j-- {
+ b = append(b, fr.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fr_YT/fr_YT.go b/fr_YT/fr_YT.go
index 2bd2760b..5fa75ae6 100644
--- a/fr_YT/fr_YT.go
+++ b/fr_YT/fr_YT.go
@@ -95,19 +95,15 @@ func (fr *fr_YT) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (fr *fr_YT) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fr.decimal) + len(fr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(fr.decimal) - 1; j >= 0; j-- {
b = append(b, fr.decimal[j])
}
@@ -118,9 +114,7 @@ func (fr *fr_YT) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(fr.group) - 1; j >= 0; j-- {
b = append(b, fr.group[j])
}
@@ -134,11 +128,16 @@ func (fr *fr_YT) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(fr.minus) - 1; j >= 0; j-- {
+ b = append(b, fr.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fur/fur.go b/fur/fur.go
index c0c2d232..d1219a56 100644
--- a/fur/fur.go
+++ b/fur/fur.go
@@ -76,36 +76,24 @@ func (fur *fur) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (fur *fur) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fur.decimal) + len(fur.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(fur.decimal) - 1; j >= 0; j-- {
- b = append(b, fur.decimal[j])
- }
-
+ b = append(b, fur.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(fur.group) - 1; j >= 0; j-- {
- b = append(b, fur.group[j])
- }
-
+ b = append(b, fur.group[0])
count = 1
} else {
count++
@@ -115,11 +103,14 @@ func (fur *fur) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, fur.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fur_IT/fur_IT.go b/fur_IT/fur_IT.go
index 34e23fff..42e49c2a 100644
--- a/fur_IT/fur_IT.go
+++ b/fur_IT/fur_IT.go
@@ -76,36 +76,24 @@ func (fur *fur_IT) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (fur *fur_IT) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fur.decimal) + len(fur.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(fur.decimal) - 1; j >= 0; j-- {
- b = append(b, fur.decimal[j])
- }
-
+ b = append(b, fur.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(fur.group) - 1; j >= 0; j-- {
- b = append(b, fur.group[j])
- }
-
+ b = append(b, fur.group[0])
count = 1
} else {
count++
@@ -115,11 +103,14 @@ func (fur *fur_IT) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, fur.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fy/fy.go b/fy/fy.go
index 1f258946..b146f484 100644
--- a/fy/fy.go
+++ b/fy/fy.go
@@ -77,36 +77,24 @@ func (fy *fy) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (fy *fy) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fy.decimal) + len(fy.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(fy.decimal) - 1; j >= 0; j-- {
- b = append(b, fy.decimal[j])
- }
-
+ b = append(b, fy.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(fy.group) - 1; j >= 0; j-- {
- b = append(b, fy.group[j])
- }
-
+ b = append(b, fy.group[0])
count = 1
} else {
count++
@@ -116,11 +104,14 @@ func (fy *fy) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, fy.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/fy_NL/fy_NL.go b/fy_NL/fy_NL.go
index 7de7441e..dfea04c0 100644
--- a/fy_NL/fy_NL.go
+++ b/fy_NL/fy_NL.go
@@ -77,36 +77,24 @@ func (fy *fy_NL) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (fy *fy_NL) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(fy.decimal) + len(fy.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(fy.decimal) - 1; j >= 0; j-- {
- b = append(b, fy.decimal[j])
- }
-
+ b = append(b, fy.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(fy.group) - 1; j >= 0; j-- {
- b = append(b, fy.group[j])
- }
-
+ b = append(b, fy.group[0])
count = 1
} else {
count++
@@ -116,11 +104,14 @@ func (fy *fy_NL) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, fy.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ga/ga.go b/ga/ga.go
index 1d0ad7b7..08ea78b6 100644
--- a/ga/ga.go
+++ b/ga/ga.go
@@ -89,36 +89,24 @@ func (ga *ga) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (ga *ga) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ga.decimal) + len(ga.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ga.decimal) - 1; j >= 0; j-- {
- b = append(b, ga.decimal[j])
- }
-
+ b = append(b, ga.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(ga.group) - 1; j >= 0; j-- {
- b = append(b, ga.group[j])
- }
-
+ b = append(b, ga.group[0])
count = 1
} else {
count++
@@ -128,11 +116,14 @@ func (ga *ga) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, ga.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ga_IE/ga_IE.go b/ga_IE/ga_IE.go
index f456b26a..f209344f 100644
--- a/ga_IE/ga_IE.go
+++ b/ga_IE/ga_IE.go
@@ -89,36 +89,24 @@ func (ga *ga_IE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ga *ga_IE) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ga.decimal) + len(ga.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ga.decimal) - 1; j >= 0; j-- {
- b = append(b, ga.decimal[j])
- }
-
+ b = append(b, ga.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(ga.group) - 1; j >= 0; j-- {
- b = append(b, ga.group[j])
- }
-
+ b = append(b, ga.group[0])
count = 1
} else {
count++
@@ -128,11 +116,14 @@ func (ga *ga_IE) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, ga.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/gd/gd.go b/gd/gd.go
index efc82096..aa802a85 100644
--- a/gd/gd.go
+++ b/gd/gd.go
@@ -80,19 +80,15 @@ func (gd *gd) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (gd *gd) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(gd.decimal) + len(gd.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(gd.decimal) - 1; j >= 0; j-- {
b = append(b, gd.decimal[j])
}
@@ -103,9 +99,7 @@ func (gd *gd) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(gd.group) - 1; j >= 0; j-- {
b = append(b, gd.group[j])
}
@@ -119,11 +113,16 @@ func (gd *gd) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(gd.minus) - 1; j >= 0; j-- {
+ b = append(b, gd.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/gd_GB/gd_GB.go b/gd_GB/gd_GB.go
index 81b0b0ce..a43aade2 100644
--- a/gd_GB/gd_GB.go
+++ b/gd_GB/gd_GB.go
@@ -80,19 +80,15 @@ func (gd *gd_GB) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (gd *gd_GB) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(gd.decimal) + len(gd.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(gd.decimal) - 1; j >= 0; j-- {
b = append(b, gd.decimal[j])
}
@@ -103,9 +99,7 @@ func (gd *gd_GB) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(gd.group) - 1; j >= 0; j-- {
b = append(b, gd.group[j])
}
@@ -119,11 +113,16 @@ func (gd *gd_GB) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(gd.minus) - 1; j >= 0; j-- {
+ b = append(b, gd.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/gl/gl.go b/gl/gl.go
index 4418cf57..fc0f5a20 100644
--- a/gl/gl.go
+++ b/gl/gl.go
@@ -88,36 +88,24 @@ func (gl *gl) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (gl *gl) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(gl.decimal) + len(gl.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(gl.decimal) - 1; j >= 0; j-- {
- b = append(b, gl.decimal[j])
- }
-
+ b = append(b, gl.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(gl.group) - 1; j >= 0; j-- {
- b = append(b, gl.group[j])
- }
-
+ b = append(b, gl.group[0])
count = 1
} else {
count++
@@ -127,11 +115,14 @@ func (gl *gl) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, gl.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/gl_ES/gl_ES.go b/gl_ES/gl_ES.go
index 3d92ca05..d25e0cf5 100644
--- a/gl_ES/gl_ES.go
+++ b/gl_ES/gl_ES.go
@@ -88,36 +88,24 @@ func (gl *gl_ES) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (gl *gl_ES) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(gl.decimal) + len(gl.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(gl.decimal) - 1; j >= 0; j-- {
- b = append(b, gl.decimal[j])
- }
-
+ b = append(b, gl.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(gl.group) - 1; j >= 0; j-- {
- b = append(b, gl.group[j])
- }
-
+ b = append(b, gl.group[0])
count = 1
} else {
count++
@@ -127,11 +115,14 @@ func (gl *gl_ES) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, gl.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/gsw/gsw.go b/gsw/gsw.go
index e03ba329..80dcaa8b 100644
--- a/gsw/gsw.go
+++ b/gsw/gsw.go
@@ -76,32 +76,23 @@ func (gsw *gsw) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (gsw *gsw) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(gsw.decimal) + len(gsw.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(gsw.decimal) - 1; j >= 0; j-- {
- b = append(b, gsw.decimal[j])
- }
-
+ b = append(b, gsw.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(gsw.group) - 1; j >= 0; j-- {
b = append(b, gsw.group[j])
}
@@ -115,11 +106,16 @@ func (gsw *gsw) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(gsw.minus) - 1; j >= 0; j-- {
+ b = append(b, gsw.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/gsw_CH/gsw_CH.go b/gsw_CH/gsw_CH.go
index 434c0e5f..7b147c6c 100644
--- a/gsw_CH/gsw_CH.go
+++ b/gsw_CH/gsw_CH.go
@@ -76,32 +76,23 @@ func (gsw *gsw_CH) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (gsw *gsw_CH) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(gsw.decimal) + len(gsw.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(gsw.decimal) - 1; j >= 0; j-- {
- b = append(b, gsw.decimal[j])
- }
-
+ b = append(b, gsw.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(gsw.group) - 1; j >= 0; j-- {
b = append(b, gsw.group[j])
}
@@ -115,11 +106,16 @@ func (gsw *gsw_CH) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(gsw.minus) - 1; j >= 0; j-- {
+ b = append(b, gsw.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/gsw_FR/gsw_FR.go b/gsw_FR/gsw_FR.go
index de831461..4f0ef0dd 100644
--- a/gsw_FR/gsw_FR.go
+++ b/gsw_FR/gsw_FR.go
@@ -76,32 +76,23 @@ func (gsw *gsw_FR) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (gsw *gsw_FR) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(gsw.decimal) + len(gsw.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(gsw.decimal) - 1; j >= 0; j-- {
- b = append(b, gsw.decimal[j])
- }
-
+ b = append(b, gsw.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(gsw.group) - 1; j >= 0; j-- {
b = append(b, gsw.group[j])
}
@@ -115,11 +106,16 @@ func (gsw *gsw_FR) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(gsw.minus) - 1; j >= 0; j-- {
+ b = append(b, gsw.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/gsw_LI/gsw_LI.go b/gsw_LI/gsw_LI.go
index 8988c50c..ffe9f4e5 100644
--- a/gsw_LI/gsw_LI.go
+++ b/gsw_LI/gsw_LI.go
@@ -76,32 +76,23 @@ func (gsw *gsw_LI) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (gsw *gsw_LI) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(gsw.decimal) + len(gsw.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(gsw.decimal) - 1; j >= 0; j-- {
- b = append(b, gsw.decimal[j])
- }
-
+ b = append(b, gsw.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(gsw.group) - 1; j >= 0; j-- {
b = append(b, gsw.group[j])
}
@@ -115,11 +106,16 @@ func (gsw *gsw_LI) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(gsw.minus) - 1; j >= 0; j-- {
+ b = append(b, gsw.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/gu/gu.go b/gu/gu.go
index b21efd70..43723f4e 100644
--- a/gu/gu.go
+++ b/gu/gu.go
@@ -101,19 +101,18 @@ func (gu *gu) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (gu *gu) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(gu.decimal) + len(gu.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
+ inSecondary := false
+ groupThreshold := 3
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(gu.decimal) - 1; j >= 0; j-- {
b = append(b, gu.decimal[j])
}
@@ -125,13 +124,17 @@ func (gu *gu) FmtNumber(num float64, v uint64) []byte {
if inWhole {
- if count == 3 {
-
+ if count == groupThreshold {
for j := len(gu.group) - 1; j >= 0; j-- {
b = append(b, gu.group[j])
}
count = 1
+
+ if !inSecondary {
+ inSecondary = true
+ groupThreshold = 2
+ }
} else {
count++
}
@@ -140,11 +143,16 @@ func (gu *gu) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(gu.minus) - 1; j >= 0; j-- {
+ b = append(b, gu.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/gu_IN/gu_IN.go b/gu_IN/gu_IN.go
index 30bfa438..64ca445c 100644
--- a/gu_IN/gu_IN.go
+++ b/gu_IN/gu_IN.go
@@ -101,19 +101,18 @@ func (gu *gu_IN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (gu *gu_IN) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(gu.decimal) + len(gu.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
+ inSecondary := false
+ groupThreshold := 3
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(gu.decimal) - 1; j >= 0; j-- {
b = append(b, gu.decimal[j])
}
@@ -125,13 +124,17 @@ func (gu *gu_IN) FmtNumber(num float64, v uint64) []byte {
if inWhole {
- if count == 3 {
-
+ if count == groupThreshold {
for j := len(gu.group) - 1; j >= 0; j-- {
b = append(b, gu.group[j])
}
count = 1
+
+ if !inSecondary {
+ inSecondary = true
+ groupThreshold = 2
+ }
} else {
count++
}
@@ -140,11 +143,16 @@ func (gu *gu_IN) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(gu.minus) - 1; j >= 0; j-- {
+ b = append(b, gu.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/guz/guz.go b/guz/guz.go
index 391159dd..24073e8e 100644
--- a/guz/guz.go
+++ b/guz/guz.go
@@ -1,6 +1,7 @@
package guz
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,8 +69,6 @@ func (guz *guz) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (guz *guz) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/guz_KE/guz_KE.go b/guz_KE/guz_KE.go
index 5a2bcdd4..2519bdf1 100644
--- a/guz_KE/guz_KE.go
+++ b/guz_KE/guz_KE.go
@@ -1,6 +1,7 @@
package guz_KE
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,8 +69,6 @@ func (guz *guz_KE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (guz *guz_KE) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/gv/gv.go b/gv/gv.go
index 54b14fe0..9357190f 100644
--- a/gv/gv.go
+++ b/gv/gv.go
@@ -85,8 +85,6 @@ func (gv *gv) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (gv *gv) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/gv_IM/gv_IM.go b/gv_IM/gv_IM.go
index 57dd231c..38ac77e6 100644
--- a/gv_IM/gv_IM.go
+++ b/gv_IM/gv_IM.go
@@ -85,8 +85,6 @@ func (gv *gv_IM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (gv *gv_IM) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/ha/ha.go b/ha/ha.go
index c793510d..893705bc 100644
--- a/ha/ha.go
+++ b/ha/ha.go
@@ -76,36 +76,24 @@ func (ha *ha) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (ha *ha) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ha.decimal) + len(ha.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ha.decimal) - 1; j >= 0; j-- {
- b = append(b, ha.decimal[j])
- }
-
+ b = append(b, ha.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(ha.group) - 1; j >= 0; j-- {
- b = append(b, ha.group[j])
- }
-
+ b = append(b, ha.group[0])
count = 1
} else {
count++
@@ -115,11 +103,16 @@ func (ha *ha) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(ha.minus) - 1; j >= 0; j-- {
+ b = append(b, ha.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ha_GH/ha_GH.go b/ha_GH/ha_GH.go
index d19d59c5..1d5de856 100644
--- a/ha_GH/ha_GH.go
+++ b/ha_GH/ha_GH.go
@@ -76,36 +76,24 @@ func (ha *ha_GH) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ha *ha_GH) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ha.decimal) + len(ha.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ha.decimal) - 1; j >= 0; j-- {
- b = append(b, ha.decimal[j])
- }
-
+ b = append(b, ha.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(ha.group) - 1; j >= 0; j-- {
- b = append(b, ha.group[j])
- }
-
+ b = append(b, ha.group[0])
count = 1
} else {
count++
@@ -115,11 +103,16 @@ func (ha *ha_GH) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(ha.minus) - 1; j >= 0; j-- {
+ b = append(b, ha.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ha_NE/ha_NE.go b/ha_NE/ha_NE.go
index b8d9e017..3d59f342 100644
--- a/ha_NE/ha_NE.go
+++ b/ha_NE/ha_NE.go
@@ -76,36 +76,24 @@ func (ha *ha_NE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ha *ha_NE) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ha.decimal) + len(ha.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ha.decimal) - 1; j >= 0; j-- {
- b = append(b, ha.decimal[j])
- }
-
+ b = append(b, ha.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(ha.group) - 1; j >= 0; j-- {
- b = append(b, ha.group[j])
- }
-
+ b = append(b, ha.group[0])
count = 1
} else {
count++
@@ -115,11 +103,16 @@ func (ha *ha_NE) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(ha.minus) - 1; j >= 0; j-- {
+ b = append(b, ha.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ha_NG/ha_NG.go b/ha_NG/ha_NG.go
index fe8fb374..31fd84bc 100644
--- a/ha_NG/ha_NG.go
+++ b/ha_NG/ha_NG.go
@@ -76,36 +76,24 @@ func (ha *ha_NG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ha *ha_NG) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ha.decimal) + len(ha.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ha.decimal) - 1; j >= 0; j-- {
- b = append(b, ha.decimal[j])
- }
-
+ b = append(b, ha.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(ha.group) - 1; j >= 0; j-- {
- b = append(b, ha.group[j])
- }
-
+ b = append(b, ha.group[0])
count = 1
} else {
count++
@@ -115,11 +103,16 @@ func (ha *ha_NG) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(ha.minus) - 1; j >= 0; j-- {
+ b = append(b, ha.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/haw/haw.go b/haw/haw.go
index d9fd0a4e..4f1861cd 100644
--- a/haw/haw.go
+++ b/haw/haw.go
@@ -76,8 +76,6 @@ func (haw *haw) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (haw *haw) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/haw_US/haw_US.go b/haw_US/haw_US.go
index 42f5196c..f77e3032 100644
--- a/haw_US/haw_US.go
+++ b/haw_US/haw_US.go
@@ -76,8 +76,6 @@ func (haw *haw_US) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (haw *haw_US) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/he/he.go b/he/he.go
index d88558a3..82206e26 100644
--- a/he/he.go
+++ b/he/he.go
@@ -109,36 +109,24 @@ func (he *he) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (he *he) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(he.decimal) + len(he.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(he.decimal) - 1; j >= 0; j-- {
- b = append(b, he.decimal[j])
- }
-
+ b = append(b, he.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(he.group) - 1; j >= 0; j-- {
- b = append(b, he.group[j])
- }
-
+ b = append(b, he.group[0])
count = 1
} else {
count++
@@ -148,11 +136,16 @@ func (he *he) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(he.minus) - 1; j >= 0; j-- {
+ b = append(b, he.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/he_IL/he_IL.go b/he_IL/he_IL.go
index 30f69bf2..4b1e7fa0 100644
--- a/he_IL/he_IL.go
+++ b/he_IL/he_IL.go
@@ -109,36 +109,24 @@ func (he *he_IL) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (he *he_IL) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(he.decimal) + len(he.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(he.decimal) - 1; j >= 0; j-- {
- b = append(b, he.decimal[j])
- }
-
+ b = append(b, he.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(he.group) - 1; j >= 0; j-- {
- b = append(b, he.group[j])
- }
-
+ b = append(b, he.group[0])
count = 1
} else {
count++
@@ -148,11 +136,16 @@ func (he *he_IL) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(he.minus) - 1; j >= 0; j-- {
+ b = append(b, he.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/hi/hi.go b/hi/hi.go
index ea37636d..0127a4dd 100644
--- a/hi/hi.go
+++ b/hi/hi.go
@@ -101,23 +101,19 @@ func (hi *hi) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (hi *hi) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(hi.decimal) + len(hi.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
+ inSecondary := false
+ groupThreshold := 3
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(hi.decimal) - 1; j >= 0; j-- {
- b = append(b, hi.decimal[j])
- }
-
+ b = append(b, hi.decimal[0])
inWhole = true
continue
@@ -125,13 +121,14 @@ func (hi *hi) FmtNumber(num float64, v uint64) []byte {
if inWhole {
- if count == 3 {
+ if count == groupThreshold {
+ b = append(b, hi.group[0])
+ count = 1
- for j := len(hi.group) - 1; j >= 0; j-- {
- b = append(b, hi.group[j])
+ if !inSecondary {
+ inSecondary = true
+ groupThreshold = 2
}
-
- count = 1
} else {
count++
}
@@ -140,11 +137,14 @@ func (hi *hi) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, hi.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/hi_IN/hi_IN.go b/hi_IN/hi_IN.go
index cc66e8fc..fc750a19 100644
--- a/hi_IN/hi_IN.go
+++ b/hi_IN/hi_IN.go
@@ -101,23 +101,19 @@ func (hi *hi_IN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (hi *hi_IN) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(hi.decimal) + len(hi.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
+ inSecondary := false
+ groupThreshold := 3
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(hi.decimal) - 1; j >= 0; j-- {
- b = append(b, hi.decimal[j])
- }
-
+ b = append(b, hi.decimal[0])
inWhole = true
continue
@@ -125,13 +121,14 @@ func (hi *hi_IN) FmtNumber(num float64, v uint64) []byte {
if inWhole {
- if count == 3 {
+ if count == groupThreshold {
+ b = append(b, hi.group[0])
+ count = 1
- for j := len(hi.group) - 1; j >= 0; j-- {
- b = append(b, hi.group[j])
+ if !inSecondary {
+ inSecondary = true
+ groupThreshold = 2
}
-
- count = 1
} else {
count++
}
@@ -140,11 +137,14 @@ func (hi *hi_IN) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, hi.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/hr/hr.go b/hr/hr.go
index 544d6731..dfc170cd 100644
--- a/hr/hr.go
+++ b/hr/hr.go
@@ -55,8 +55,8 @@ func (hr *hr) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
n := math.Abs(num)
i := int64(n)
f := locales.F(n, v)
- iMod10 := i % 10
iMod100 := i % 100
+ iMod10 := i % 10
fMod10 := f % 10
fMod100 := f % 100
@@ -107,36 +107,24 @@ func (hr *hr) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (hr *hr) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(hr.decimal) + len(hr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(hr.decimal) - 1; j >= 0; j-- {
- b = append(b, hr.decimal[j])
- }
-
+ b = append(b, hr.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(hr.group) - 1; j >= 0; j-- {
- b = append(b, hr.group[j])
- }
-
+ b = append(b, hr.group[0])
count = 1
} else {
count++
@@ -146,11 +134,14 @@ func (hr *hr) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, hr.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/hr_BA/hr_BA.go b/hr_BA/hr_BA.go
index 73dccafc..5ed4c3d3 100644
--- a/hr_BA/hr_BA.go
+++ b/hr_BA/hr_BA.go
@@ -55,8 +55,8 @@ func (hr *hr_BA) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
n := math.Abs(num)
i := int64(n)
f := locales.F(n, v)
- iMod10 := i % 10
iMod100 := i % 100
+ iMod10 := i % 10
fMod10 := f % 10
fMod100 := f % 100
@@ -107,36 +107,24 @@ func (hr *hr_BA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (hr *hr_BA) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(hr.decimal) + len(hr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(hr.decimal) - 1; j >= 0; j-- {
- b = append(b, hr.decimal[j])
- }
-
+ b = append(b, hr.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(hr.group) - 1; j >= 0; j-- {
- b = append(b, hr.group[j])
- }
-
+ b = append(b, hr.group[0])
count = 1
} else {
count++
@@ -146,11 +134,14 @@ func (hr *hr_BA) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, hr.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/hr_HR/hr_HR.go b/hr_HR/hr_HR.go
index 23e75d5d..a2f8d8bc 100644
--- a/hr_HR/hr_HR.go
+++ b/hr_HR/hr_HR.go
@@ -55,8 +55,8 @@ func (hr *hr_HR) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
n := math.Abs(num)
i := int64(n)
f := locales.F(n, v)
- iMod100 := i % 100
iMod10 := i % 10
+ iMod100 := i % 100
fMod10 := f % 10
fMod100 := f % 100
@@ -107,36 +107,24 @@ func (hr *hr_HR) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (hr *hr_HR) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(hr.decimal) + len(hr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(hr.decimal) - 1; j >= 0; j-- {
- b = append(b, hr.decimal[j])
- }
-
+ b = append(b, hr.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(hr.group) - 1; j >= 0; j-- {
- b = append(b, hr.group[j])
- }
-
+ b = append(b, hr.group[0])
count = 1
} else {
count++
@@ -146,11 +134,14 @@ func (hr *hr_HR) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, hr.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/hsb/hsb.go b/hsb/hsb.go
index 4930222f..cfa4fcfc 100644
--- a/hsb/hsb.go
+++ b/hsb/hsb.go
@@ -84,36 +84,24 @@ func (hsb *hsb) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (hsb *hsb) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(hsb.decimal) + len(hsb.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(hsb.decimal) - 1; j >= 0; j-- {
- b = append(b, hsb.decimal[j])
- }
-
+ b = append(b, hsb.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(hsb.group) - 1; j >= 0; j-- {
- b = append(b, hsb.group[j])
- }
-
+ b = append(b, hsb.group[0])
count = 1
} else {
count++
@@ -123,11 +111,14 @@ func (hsb *hsb) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, hsb.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/hsb_DE/hsb_DE.go b/hsb_DE/hsb_DE.go
index 547e7004..bda1f7da 100644
--- a/hsb_DE/hsb_DE.go
+++ b/hsb_DE/hsb_DE.go
@@ -84,36 +84,24 @@ func (hsb *hsb_DE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (hsb *hsb_DE) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(hsb.decimal) + len(hsb.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(hsb.decimal) - 1; j >= 0; j-- {
- b = append(b, hsb.decimal[j])
- }
-
+ b = append(b, hsb.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(hsb.group) - 1; j >= 0; j-- {
- b = append(b, hsb.group[j])
- }
-
+ b = append(b, hsb.group[0])
count = 1
} else {
count++
@@ -123,11 +111,14 @@ func (hsb *hsb_DE) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, hsb.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/hu/hu.go b/hu/hu.go
index 30ce814c..62228a0b 100644
--- a/hu/hu.go
+++ b/hu/hu.go
@@ -94,32 +94,23 @@ func (hu *hu) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (hu *hu) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(hu.decimal) + len(hu.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(hu.decimal) - 1; j >= 0; j-- {
- b = append(b, hu.decimal[j])
- }
-
+ b = append(b, hu.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(hu.group) - 1; j >= 0; j-- {
b = append(b, hu.group[j])
}
@@ -133,11 +124,14 @@ func (hu *hu) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, hu.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/hu_HU/hu_HU.go b/hu_HU/hu_HU.go
index cc353892..f5299154 100644
--- a/hu_HU/hu_HU.go
+++ b/hu_HU/hu_HU.go
@@ -94,32 +94,23 @@ func (hu *hu_HU) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (hu *hu_HU) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(hu.decimal) + len(hu.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(hu.decimal) - 1; j >= 0; j-- {
- b = append(b, hu.decimal[j])
- }
-
+ b = append(b, hu.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(hu.group) - 1; j >= 0; j-- {
b = append(b, hu.group[j])
}
@@ -133,11 +124,14 @@ func (hu *hu_HU) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, hu.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/hy/hy.go b/hy/hy.go
index 2ea4e3b6..e86fc74e 100644
--- a/hy/hy.go
+++ b/hy/hy.go
@@ -95,8 +95,7 @@ func (hy *hy) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (hy *hy) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(hy.decimal)
b := make([]byte, 0, l)
@@ -104,22 +103,21 @@ func (hy *hy) FmtNumber(num float64, v uint64) []byte {
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(hy.decimal) - 1; j >= 0; j-- {
- b = append(b, hy.decimal[j])
- }
-
+ b = append(b, hy.decimal[0])
continue
}
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, hy.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/hy_AM/hy_AM.go b/hy_AM/hy_AM.go
index b4613593..ce0e3d74 100644
--- a/hy_AM/hy_AM.go
+++ b/hy_AM/hy_AM.go
@@ -95,8 +95,7 @@ func (hy *hy_AM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (hy *hy_AM) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(hy.decimal)
b := make([]byte, 0, l)
@@ -104,22 +103,21 @@ func (hy *hy_AM) FmtNumber(num float64, v uint64) []byte {
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(hy.decimal) - 1; j >= 0; j-- {
- b = append(b, hy.decimal[j])
- }
-
+ b = append(b, hy.decimal[0])
continue
}
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, hy.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/id/id.go b/id/id.go
index bf2de741..3cfbb162 100644
--- a/id/id.go
+++ b/id/id.go
@@ -1,6 +1,7 @@
package id
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,36 +69,24 @@ func (id *id) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (id *id) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(id.decimal) + len(id.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(id.decimal) - 1; j >= 0; j-- {
- b = append(b, id.decimal[j])
- }
-
+ b = append(b, id.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(id.group) - 1; j >= 0; j-- {
- b = append(b, id.group[j])
- }
-
+ b = append(b, id.group[0])
count = 1
} else {
count++
@@ -107,11 +96,14 @@ func (id *id) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, id.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/id_ID/id_ID.go b/id_ID/id_ID.go
index 3d7927e6..84499109 100644
--- a/id_ID/id_ID.go
+++ b/id_ID/id_ID.go
@@ -1,6 +1,7 @@
package id_ID
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,36 +69,24 @@ func (id *id_ID) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (id *id_ID) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(id.decimal) + len(id.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(id.decimal) - 1; j >= 0; j-- {
- b = append(b, id.decimal[j])
- }
-
+ b = append(b, id.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(id.group) - 1; j >= 0; j-- {
- b = append(b, id.group[j])
- }
-
+ b = append(b, id.group[0])
count = 1
} else {
count++
@@ -107,11 +96,14 @@ func (id *id_ID) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, id.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ig/ig.go b/ig/ig.go
index ed538c34..9f5d0be8 100644
--- a/ig/ig.go
+++ b/ig/ig.go
@@ -1,6 +1,7 @@
package ig
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,8 +69,6 @@ func (ig *ig) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (ig *ig) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/ig_NG/ig_NG.go b/ig_NG/ig_NG.go
index b97a546d..f07ef2d5 100644
--- a/ig_NG/ig_NG.go
+++ b/ig_NG/ig_NG.go
@@ -1,6 +1,7 @@
package ig_NG
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,8 +69,6 @@ func (ig *ig_NG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ig *ig_NG) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/ii/ii.go b/ii/ii.go
index eb78f989..c8eb9c6f 100644
--- a/ii/ii.go
+++ b/ii/ii.go
@@ -1,6 +1,7 @@
package ii
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,8 +69,6 @@ func (ii *ii) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (ii *ii) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/ii_CN/ii_CN.go b/ii_CN/ii_CN.go
index 9fbdd0b5..9a0a2b90 100644
--- a/ii_CN/ii_CN.go
+++ b/ii_CN/ii_CN.go
@@ -1,6 +1,7 @@
package ii_CN
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,8 +69,6 @@ func (ii *ii_CN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ii *ii_CN) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/is/is.go b/is/is.go
index ccb53881..4f199a98 100644
--- a/is/is.go
+++ b/is/is.go
@@ -93,36 +93,24 @@ func (is *is) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (is *is) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(is.decimal) + len(is.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(is.decimal) - 1; j >= 0; j-- {
- b = append(b, is.decimal[j])
- }
-
+ b = append(b, is.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(is.group) - 1; j >= 0; j-- {
- b = append(b, is.group[j])
- }
-
+ b = append(b, is.group[0])
count = 1
} else {
count++
@@ -132,11 +120,14 @@ func (is *is) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, is.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/is_IS/is_IS.go b/is_IS/is_IS.go
index 5e81c7c3..5f57e7c4 100644
--- a/is_IS/is_IS.go
+++ b/is_IS/is_IS.go
@@ -93,36 +93,24 @@ func (is *is_IS) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (is *is_IS) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(is.decimal) + len(is.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(is.decimal) - 1; j >= 0; j-- {
- b = append(b, is.decimal[j])
- }
-
+ b = append(b, is.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(is.group) - 1; j >= 0; j-- {
- b = append(b, is.group[j])
- }
-
+ b = append(b, is.group[0])
count = 1
} else {
count++
@@ -132,11 +120,14 @@ func (is *is_IS) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, is.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/it/it.go b/it/it.go
index 54602e1e..c1ac02db 100644
--- a/it/it.go
+++ b/it/it.go
@@ -95,36 +95,24 @@ func (it *it) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (it *it) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(it.decimal) + len(it.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(it.decimal) - 1; j >= 0; j-- {
- b = append(b, it.decimal[j])
- }
-
+ b = append(b, it.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(it.group) - 1; j >= 0; j-- {
- b = append(b, it.group[j])
- }
-
+ b = append(b, it.group[0])
count = 1
} else {
count++
@@ -134,11 +122,14 @@ func (it *it) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, it.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/it_CH/it_CH.go b/it_CH/it_CH.go
index aa92b8af..68a14342 100644
--- a/it_CH/it_CH.go
+++ b/it_CH/it_CH.go
@@ -95,36 +95,24 @@ func (it *it_CH) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (it *it_CH) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(it.decimal) + len(it.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(it.decimal) - 1; j >= 0; j-- {
- b = append(b, it.decimal[j])
- }
-
+ b = append(b, it.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(it.group) - 1; j >= 0; j-- {
- b = append(b, it.group[j])
- }
-
+ b = append(b, it.group[0])
count = 1
} else {
count++
@@ -134,11 +122,14 @@ func (it *it_CH) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, it.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/it_IT/it_IT.go b/it_IT/it_IT.go
index ba1274f0..5068d50d 100644
--- a/it_IT/it_IT.go
+++ b/it_IT/it_IT.go
@@ -95,36 +95,24 @@ func (it *it_IT) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (it *it_IT) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(it.decimal) + len(it.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(it.decimal) - 1; j >= 0; j-- {
- b = append(b, it.decimal[j])
- }
-
+ b = append(b, it.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(it.group) - 1; j >= 0; j-- {
- b = append(b, it.group[j])
- }
-
+ b = append(b, it.group[0])
count = 1
} else {
count++
@@ -134,11 +122,14 @@ func (it *it_IT) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, it.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/it_SM/it_SM.go b/it_SM/it_SM.go
index 65381c3c..58e28412 100644
--- a/it_SM/it_SM.go
+++ b/it_SM/it_SM.go
@@ -95,36 +95,24 @@ func (it *it_SM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (it *it_SM) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(it.decimal) + len(it.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(it.decimal) - 1; j >= 0; j-- {
- b = append(b, it.decimal[j])
- }
-
+ b = append(b, it.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(it.group) - 1; j >= 0; j-- {
- b = append(b, it.group[j])
- }
-
+ b = append(b, it.group[0])
count = 1
} else {
count++
@@ -134,11 +122,14 @@ func (it *it_SM) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, it.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ja/ja.go b/ja/ja.go
index 92d5ef9a..d708e18a 100644
--- a/ja/ja.go
+++ b/ja/ja.go
@@ -1,6 +1,7 @@
package ja
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,36 +69,24 @@ func (ja *ja) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (ja *ja) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ja.decimal) + len(ja.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ja.decimal) - 1; j >= 0; j-- {
- b = append(b, ja.decimal[j])
- }
-
+ b = append(b, ja.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(ja.group) - 1; j >= 0; j-- {
- b = append(b, ja.group[j])
- }
-
+ b = append(b, ja.group[0])
count = 1
} else {
count++
@@ -107,11 +96,14 @@ func (ja *ja) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, ja.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ja_JP/ja_JP.go b/ja_JP/ja_JP.go
index a8021b98..c0bdda1b 100644
--- a/ja_JP/ja_JP.go
+++ b/ja_JP/ja_JP.go
@@ -1,6 +1,7 @@
package ja_JP
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,36 +69,24 @@ func (ja *ja_JP) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ja *ja_JP) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ja.decimal) + len(ja.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ja.decimal) - 1; j >= 0; j-- {
- b = append(b, ja.decimal[j])
- }
-
+ b = append(b, ja.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(ja.group) - 1; j >= 0; j-- {
- b = append(b, ja.group[j])
- }
-
+ b = append(b, ja.group[0])
count = 1
} else {
count++
@@ -107,11 +96,14 @@ func (ja *ja_JP) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, ja.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/jgo/jgo.go b/jgo/jgo.go
index 5b027ad9..097ab914 100644
--- a/jgo/jgo.go
+++ b/jgo/jgo.go
@@ -76,36 +76,24 @@ func (jgo *jgo) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (jgo *jgo) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(jgo.decimal) + len(jgo.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(jgo.decimal) - 1; j >= 0; j-- {
- b = append(b, jgo.decimal[j])
- }
-
+ b = append(b, jgo.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(jgo.group) - 1; j >= 0; j-- {
- b = append(b, jgo.group[j])
- }
-
+ b = append(b, jgo.group[0])
count = 1
} else {
count++
@@ -115,11 +103,14 @@ func (jgo *jgo) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, jgo.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/jgo_CM/jgo_CM.go b/jgo_CM/jgo_CM.go
index a0177687..c852ee71 100644
--- a/jgo_CM/jgo_CM.go
+++ b/jgo_CM/jgo_CM.go
@@ -76,36 +76,24 @@ func (jgo *jgo_CM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (jgo *jgo_CM) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(jgo.decimal) + len(jgo.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(jgo.decimal) - 1; j >= 0; j-- {
- b = append(b, jgo.decimal[j])
- }
-
+ b = append(b, jgo.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(jgo.group) - 1; j >= 0; j-- {
- b = append(b, jgo.group[j])
- }
-
+ b = append(b, jgo.group[0])
count = 1
} else {
count++
@@ -115,11 +103,14 @@ func (jgo *jgo_CM) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, jgo.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/jmc/jmc.go b/jmc/jmc.go
index 60c052e8..72ceef2e 100644
--- a/jmc/jmc.go
+++ b/jmc/jmc.go
@@ -76,8 +76,6 @@ func (jmc *jmc) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (jmc *jmc) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/jmc_TZ/jmc_TZ.go b/jmc_TZ/jmc_TZ.go
index 58b463ab..6928fcf3 100644
--- a/jmc_TZ/jmc_TZ.go
+++ b/jmc_TZ/jmc_TZ.go
@@ -76,8 +76,6 @@ func (jmc *jmc_TZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (jmc *jmc_TZ) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/ka/ka.go b/ka/ka.go
index 7b71457b..d9ec0741 100644
--- a/ka/ka.go
+++ b/ka/ka.go
@@ -98,32 +98,23 @@ func (ka *ka) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (ka *ka) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ka.decimal) + len(ka.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ka.decimal) - 1; j >= 0; j-- {
- b = append(b, ka.decimal[j])
- }
-
+ b = append(b, ka.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(ka.group) - 1; j >= 0; j-- {
b = append(b, ka.group[j])
}
@@ -137,11 +128,14 @@ func (ka *ka) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, ka.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ka_GE/ka_GE.go b/ka_GE/ka_GE.go
index 3956afb2..c9adcf7d 100644
--- a/ka_GE/ka_GE.go
+++ b/ka_GE/ka_GE.go
@@ -98,32 +98,23 @@ func (ka *ka_GE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ka *ka_GE) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ka.decimal) + len(ka.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ka.decimal) - 1; j >= 0; j-- {
- b = append(b, ka.decimal[j])
- }
-
+ b = append(b, ka.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(ka.group) - 1; j >= 0; j-- {
b = append(b, ka.group[j])
}
@@ -137,11 +128,14 @@ func (ka *ka_GE) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, ka.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/kab/kab.go b/kab/kab.go
index e469c4a7..db7ec8be 100644
--- a/kab/kab.go
+++ b/kab/kab.go
@@ -77,8 +77,6 @@ func (kab *kab) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (kab *kab) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/kab_DZ/kab_DZ.go b/kab_DZ/kab_DZ.go
index a9454bb9..3dfcdccb 100644
--- a/kab_DZ/kab_DZ.go
+++ b/kab_DZ/kab_DZ.go
@@ -77,8 +77,6 @@ func (kab *kab_DZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (kab *kab_DZ) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/kam/kam.go b/kam/kam.go
index c52ca10f..7df50bdd 100644
--- a/kam/kam.go
+++ b/kam/kam.go
@@ -1,6 +1,7 @@
package kam
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,8 +69,6 @@ func (kam *kam) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (kam *kam) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/kam_KE/kam_KE.go b/kam_KE/kam_KE.go
index 146dddd2..0b63ba85 100644
--- a/kam_KE/kam_KE.go
+++ b/kam_KE/kam_KE.go
@@ -1,6 +1,7 @@
package kam_KE
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,8 +69,6 @@ func (kam *kam_KE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (kam *kam_KE) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/kde/kde.go b/kde/kde.go
index f02a939a..e443bd7c 100644
--- a/kde/kde.go
+++ b/kde/kde.go
@@ -1,6 +1,7 @@
package kde
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,8 +69,6 @@ func (kde *kde) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (kde *kde) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/kde_TZ/kde_TZ.go b/kde_TZ/kde_TZ.go
index 322ca58c..38ed2638 100644
--- a/kde_TZ/kde_TZ.go
+++ b/kde_TZ/kde_TZ.go
@@ -1,6 +1,7 @@
package kde_TZ
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,8 +69,6 @@ func (kde *kde_TZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (kde *kde_TZ) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/kea/kea.go b/kea/kea.go
index b7747a0d..8ce7e9bf 100644
--- a/kea/kea.go
+++ b/kea/kea.go
@@ -1,6 +1,7 @@
package kea
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,32 +69,23 @@ func (kea *kea) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (kea *kea) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(kea.decimal) + len(kea.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(kea.decimal) - 1; j >= 0; j-- {
- b = append(b, kea.decimal[j])
- }
-
+ b = append(b, kea.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(kea.group) - 1; j >= 0; j-- {
b = append(b, kea.group[j])
}
@@ -107,11 +99,14 @@ func (kea *kea) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, kea.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/kea_CV/kea_CV.go b/kea_CV/kea_CV.go
index d8f2e50b..030391c3 100644
--- a/kea_CV/kea_CV.go
+++ b/kea_CV/kea_CV.go
@@ -1,6 +1,7 @@
package kea_CV
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,32 +69,23 @@ func (kea *kea_CV) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (kea *kea_CV) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(kea.decimal) + len(kea.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(kea.decimal) - 1; j >= 0; j-- {
- b = append(b, kea.decimal[j])
- }
-
+ b = append(b, kea.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(kea.group) - 1; j >= 0; j-- {
b = append(b, kea.group[j])
}
@@ -107,11 +99,14 @@ func (kea *kea_CV) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, kea.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/khq/khq.go b/khq/khq.go
index 9ae640be..cedcd49f 100644
--- a/khq/khq.go
+++ b/khq/khq.go
@@ -1,6 +1,7 @@
package khq
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,8 +69,6 @@ func (khq *khq) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (khq *khq) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/khq_ML/khq_ML.go b/khq_ML/khq_ML.go
index 8281a21a..afdc4a2f 100644
--- a/khq_ML/khq_ML.go
+++ b/khq_ML/khq_ML.go
@@ -1,6 +1,7 @@
package khq_ML
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,8 +69,6 @@ func (khq *khq_ML) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (khq *khq_ML) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/ki/ki.go b/ki/ki.go
index 1efc4a0e..beb9b1e9 100644
--- a/ki/ki.go
+++ b/ki/ki.go
@@ -1,6 +1,7 @@
package ki
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,8 +69,6 @@ func (ki *ki) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (ki *ki) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/ki_KE/ki_KE.go b/ki_KE/ki_KE.go
index 826ee10b..3b823e57 100644
--- a/ki_KE/ki_KE.go
+++ b/ki_KE/ki_KE.go
@@ -1,6 +1,7 @@
package ki_KE
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,8 +69,6 @@ func (ki *ki_KE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ki *ki_KE) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/kk/kk.go b/kk/kk.go
index 7eecf068..fd9a17cb 100644
--- a/kk/kk.go
+++ b/kk/kk.go
@@ -95,32 +95,23 @@ func (kk *kk) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (kk *kk) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(kk.decimal) + len(kk.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(kk.decimal) - 1; j >= 0; j-- {
- b = append(b, kk.decimal[j])
- }
-
+ b = append(b, kk.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(kk.group) - 1; j >= 0; j-- {
b = append(b, kk.group[j])
}
@@ -134,11 +125,14 @@ func (kk *kk) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, kk.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/kk_KZ/kk_KZ.go b/kk_KZ/kk_KZ.go
index 168c72cf..3ba5a55f 100644
--- a/kk_KZ/kk_KZ.go
+++ b/kk_KZ/kk_KZ.go
@@ -95,32 +95,23 @@ func (kk *kk_KZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (kk *kk_KZ) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(kk.decimal) + len(kk.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(kk.decimal) - 1; j >= 0; j-- {
- b = append(b, kk.decimal[j])
- }
-
+ b = append(b, kk.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(kk.group) - 1; j >= 0; j-- {
b = append(b, kk.group[j])
}
@@ -134,11 +125,14 @@ func (kk *kk_KZ) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, kk.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/kkj/kkj.go b/kkj/kkj.go
index 97d59027..e0b7ac4a 100644
--- a/kkj/kkj.go
+++ b/kkj/kkj.go
@@ -76,8 +76,6 @@ func (kkj *kkj) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (kkj *kkj) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/kkj_CM/kkj_CM.go b/kkj_CM/kkj_CM.go
index ddc756d6..09e3597f 100644
--- a/kkj_CM/kkj_CM.go
+++ b/kkj_CM/kkj_CM.go
@@ -76,8 +76,6 @@ func (kkj *kkj_CM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (kkj *kkj_CM) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/kl/kl.go b/kl/kl.go
index b8636c29..eb792481 100644
--- a/kl/kl.go
+++ b/kl/kl.go
@@ -76,36 +76,24 @@ func (kl *kl) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (kl *kl) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(kl.decimal) + len(kl.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(kl.decimal) - 1; j >= 0; j-- {
- b = append(b, kl.decimal[j])
- }
-
+ b = append(b, kl.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(kl.group) - 1; j >= 0; j-- {
- b = append(b, kl.group[j])
- }
-
+ b = append(b, kl.group[0])
count = 1
} else {
count++
@@ -115,11 +103,14 @@ func (kl *kl) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, kl.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/kl_GL/kl_GL.go b/kl_GL/kl_GL.go
index cee27339..5820966d 100644
--- a/kl_GL/kl_GL.go
+++ b/kl_GL/kl_GL.go
@@ -76,36 +76,24 @@ func (kl *kl_GL) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (kl *kl_GL) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(kl.decimal) + len(kl.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(kl.decimal) - 1; j >= 0; j-- {
- b = append(b, kl.decimal[j])
- }
-
+ b = append(b, kl.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(kl.group) - 1; j >= 0; j-- {
- b = append(b, kl.group[j])
- }
-
+ b = append(b, kl.group[0])
count = 1
} else {
count++
@@ -115,11 +103,14 @@ func (kl *kl_GL) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, kl.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/kln/kln.go b/kln/kln.go
index c11cc6e1..22825560 100644
--- a/kln/kln.go
+++ b/kln/kln.go
@@ -1,6 +1,7 @@
package kln
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,8 +69,6 @@ func (kln *kln) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (kln *kln) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/kln_KE/kln_KE.go b/kln_KE/kln_KE.go
index 51062fa3..5c36bfd4 100644
--- a/kln_KE/kln_KE.go
+++ b/kln_KE/kln_KE.go
@@ -1,6 +1,7 @@
package kln_KE
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,8 +69,6 @@ func (kln *kln_KE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (kln *kln_KE) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/km/km.go b/km/km.go
index b76ec72f..6e364fd6 100644
--- a/km/km.go
+++ b/km/km.go
@@ -1,6 +1,7 @@
package km
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,36 +69,24 @@ func (km *km) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (km *km) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(km.decimal) + len(km.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(km.decimal) - 1; j >= 0; j-- {
- b = append(b, km.decimal[j])
- }
-
+ b = append(b, km.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(km.group) - 1; j >= 0; j-- {
- b = append(b, km.group[j])
- }
-
+ b = append(b, km.group[0])
count = 1
} else {
count++
@@ -107,11 +96,14 @@ func (km *km) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, km.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/km_KH/km_KH.go b/km_KH/km_KH.go
index 13451d63..13bf38b3 100644
--- a/km_KH/km_KH.go
+++ b/km_KH/km_KH.go
@@ -1,6 +1,7 @@
package km_KH
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,36 +69,24 @@ func (km *km_KH) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (km *km_KH) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(km.decimal) + len(km.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(km.decimal) - 1; j >= 0; j-- {
- b = append(b, km.decimal[j])
- }
-
+ b = append(b, km.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(km.group) - 1; j >= 0; j-- {
- b = append(b, km.group[j])
- }
-
+ b = append(b, km.group[0])
count = 1
} else {
count++
@@ -107,11 +96,14 @@ func (km *km_KH) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, km.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/kn/kn.go b/kn/kn.go
index 4d4eca78..8741a2e9 100644
--- a/kn/kn.go
+++ b/kn/kn.go
@@ -88,36 +88,24 @@ func (kn *kn) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (kn *kn) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(kn.decimal) + len(kn.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(kn.decimal) - 1; j >= 0; j-- {
- b = append(b, kn.decimal[j])
- }
-
+ b = append(b, kn.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(kn.group) - 1; j >= 0; j-- {
- b = append(b, kn.group[j])
- }
-
+ b = append(b, kn.group[0])
count = 1
} else {
count++
@@ -127,11 +115,14 @@ func (kn *kn) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, kn.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/kn_IN/kn_IN.go b/kn_IN/kn_IN.go
index 9ef05c7f..985805a0 100644
--- a/kn_IN/kn_IN.go
+++ b/kn_IN/kn_IN.go
@@ -88,36 +88,24 @@ func (kn *kn_IN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (kn *kn_IN) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(kn.decimal) + len(kn.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(kn.decimal) - 1; j >= 0; j-- {
- b = append(b, kn.decimal[j])
- }
-
+ b = append(b, kn.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(kn.group) - 1; j >= 0; j-- {
- b = append(b, kn.group[j])
- }
-
+ b = append(b, kn.group[0])
count = 1
} else {
count++
@@ -127,11 +115,14 @@ func (kn *kn_IN) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, kn.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ko/ko.go b/ko/ko.go
index 0edf4e0e..18390120 100644
--- a/ko/ko.go
+++ b/ko/ko.go
@@ -1,6 +1,7 @@
package ko
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,36 +69,24 @@ func (ko *ko) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (ko *ko) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ko.decimal) + len(ko.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ko.decimal) - 1; j >= 0; j-- {
- b = append(b, ko.decimal[j])
- }
-
+ b = append(b, ko.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(ko.group) - 1; j >= 0; j-- {
- b = append(b, ko.group[j])
- }
-
+ b = append(b, ko.group[0])
count = 1
} else {
count++
@@ -107,11 +96,14 @@ func (ko *ko) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, ko.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ko_KP/ko_KP.go b/ko_KP/ko_KP.go
index 0e544f44..a1360876 100644
--- a/ko_KP/ko_KP.go
+++ b/ko_KP/ko_KP.go
@@ -1,6 +1,7 @@
package ko_KP
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,36 +69,24 @@ func (ko *ko_KP) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ko *ko_KP) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ko.decimal) + len(ko.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ko.decimal) - 1; j >= 0; j-- {
- b = append(b, ko.decimal[j])
- }
-
+ b = append(b, ko.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(ko.group) - 1; j >= 0; j-- {
- b = append(b, ko.group[j])
- }
-
+ b = append(b, ko.group[0])
count = 1
} else {
count++
@@ -107,11 +96,14 @@ func (ko *ko_KP) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, ko.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ko_KR/ko_KR.go b/ko_KR/ko_KR.go
index f607f173..332a7e45 100644
--- a/ko_KR/ko_KR.go
+++ b/ko_KR/ko_KR.go
@@ -1,6 +1,7 @@
package ko_KR
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,36 +69,24 @@ func (ko *ko_KR) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ko *ko_KR) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ko.decimal) + len(ko.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ko.decimal) - 1; j >= 0; j-- {
- b = append(b, ko.decimal[j])
- }
-
+ b = append(b, ko.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(ko.group) - 1; j >= 0; j-- {
- b = append(b, ko.group[j])
- }
-
+ b = append(b, ko.group[0])
count = 1
} else {
count++
@@ -107,11 +96,14 @@ func (ko *ko_KR) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, ko.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/kok/kok.go b/kok/kok.go
index 02f95fc1..0c98f1f1 100644
--- a/kok/kok.go
+++ b/kok/kok.go
@@ -1,6 +1,7 @@
package kok
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,19 +69,18 @@ func (kok *kok) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (kok *kok) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(kok.decimal) + len(kok.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
+ inSecondary := false
+ groupThreshold := 3
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(kok.decimal) - 1; j >= 0; j-- {
b = append(b, kok.decimal[j])
}
@@ -92,13 +92,17 @@ func (kok *kok) FmtNumber(num float64, v uint64) []byte {
if inWhole {
- if count == 3 {
-
+ if count == groupThreshold {
for j := len(kok.group) - 1; j >= 0; j-- {
b = append(b, kok.group[j])
}
count = 1
+
+ if !inSecondary {
+ inSecondary = true
+ groupThreshold = 2
+ }
} else {
count++
}
@@ -107,11 +111,16 @@ func (kok *kok) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(kok.minus) - 1; j >= 0; j-- {
+ b = append(b, kok.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/kok_IN/kok_IN.go b/kok_IN/kok_IN.go
index c8f86f43..986b1736 100644
--- a/kok_IN/kok_IN.go
+++ b/kok_IN/kok_IN.go
@@ -1,6 +1,7 @@
package kok_IN
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,19 +69,18 @@ func (kok *kok_IN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (kok *kok_IN) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(kok.decimal) + len(kok.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
+ inSecondary := false
+ groupThreshold := 3
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(kok.decimal) - 1; j >= 0; j-- {
b = append(b, kok.decimal[j])
}
@@ -92,13 +92,17 @@ func (kok *kok_IN) FmtNumber(num float64, v uint64) []byte {
if inWhole {
- if count == 3 {
-
+ if count == groupThreshold {
for j := len(kok.group) - 1; j >= 0; j-- {
b = append(b, kok.group[j])
}
count = 1
+
+ if !inSecondary {
+ inSecondary = true
+ groupThreshold = 2
+ }
} else {
count++
}
@@ -107,11 +111,16 @@ func (kok *kok_IN) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(kok.minus) - 1; j >= 0; j-- {
+ b = append(b, kok.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ks/ks.go b/ks/ks.go
index 664408d6..e2f8b4ed 100644
--- a/ks/ks.go
+++ b/ks/ks.go
@@ -76,23 +76,19 @@ func (ks *ks) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (ks *ks) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ks.decimal) + len(ks.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
+ inSecondary := false
+ groupThreshold := 3
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ks.decimal) - 1; j >= 0; j-- {
- b = append(b, ks.decimal[j])
- }
-
+ b = append(b, ks.decimal[0])
inWhole = true
continue
@@ -100,13 +96,14 @@ func (ks *ks) FmtNumber(num float64, v uint64) []byte {
if inWhole {
- if count == 3 {
+ if count == groupThreshold {
+ b = append(b, ks.group[0])
+ count = 1
- for j := len(ks.group) - 1; j >= 0; j-- {
- b = append(b, ks.group[j])
+ if !inSecondary {
+ inSecondary = true
+ groupThreshold = 2
}
-
- count = 1
} else {
count++
}
@@ -115,11 +112,16 @@ func (ks *ks) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(ks.minus) - 1; j >= 0; j-- {
+ b = append(b, ks.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ks_IN/ks_IN.go b/ks_IN/ks_IN.go
index 6b70ed68..1d7b89b2 100644
--- a/ks_IN/ks_IN.go
+++ b/ks_IN/ks_IN.go
@@ -76,23 +76,19 @@ func (ks *ks_IN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ks *ks_IN) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ks.decimal) + len(ks.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
+ inSecondary := false
+ groupThreshold := 3
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ks.decimal) - 1; j >= 0; j-- {
- b = append(b, ks.decimal[j])
- }
-
+ b = append(b, ks.decimal[0])
inWhole = true
continue
@@ -100,13 +96,14 @@ func (ks *ks_IN) FmtNumber(num float64, v uint64) []byte {
if inWhole {
- if count == 3 {
+ if count == groupThreshold {
+ b = append(b, ks.group[0])
+ count = 1
- for j := len(ks.group) - 1; j >= 0; j-- {
- b = append(b, ks.group[j])
+ if !inSecondary {
+ inSecondary = true
+ groupThreshold = 2
}
-
- count = 1
} else {
count++
}
@@ -115,11 +112,16 @@ func (ks *ks_IN) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(ks.minus) - 1; j >= 0; j-- {
+ b = append(b, ks.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ksb/ksb.go b/ksb/ksb.go
index a78af79e..f4a65a7d 100644
--- a/ksb/ksb.go
+++ b/ksb/ksb.go
@@ -76,8 +76,6 @@ func (ksb *ksb) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (ksb *ksb) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/ksb_TZ/ksb_TZ.go b/ksb_TZ/ksb_TZ.go
index 65b4858e..961f1a80 100644
--- a/ksb_TZ/ksb_TZ.go
+++ b/ksb_TZ/ksb_TZ.go
@@ -76,8 +76,6 @@ func (ksb *ksb_TZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (ksb *ksb_TZ) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/ksf/ksf.go b/ksf/ksf.go
index 51049e79..f0a890d1 100644
--- a/ksf/ksf.go
+++ b/ksf/ksf.go
@@ -1,6 +1,7 @@
package ksf
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,32 +69,23 @@ func (ksf *ksf) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (ksf *ksf) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ksf.decimal) + len(ksf.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ksf.decimal) - 1; j >= 0; j-- {
- b = append(b, ksf.decimal[j])
- }
-
+ b = append(b, ksf.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(ksf.group) - 1; j >= 0; j-- {
b = append(b, ksf.group[j])
}
@@ -107,11 +99,16 @@ func (ksf *ksf) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(ksf.minus) - 1; j >= 0; j-- {
+ b = append(b, ksf.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ksf_CM/ksf_CM.go b/ksf_CM/ksf_CM.go
index 03a436c2..e547cf5d 100644
--- a/ksf_CM/ksf_CM.go
+++ b/ksf_CM/ksf_CM.go
@@ -1,6 +1,7 @@
package ksf_CM
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,32 +69,23 @@ func (ksf *ksf_CM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (ksf *ksf_CM) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ksf.decimal) + len(ksf.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ksf.decimal) - 1; j >= 0; j-- {
- b = append(b, ksf.decimal[j])
- }
-
+ b = append(b, ksf.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(ksf.group) - 1; j >= 0; j-- {
b = append(b, ksf.group[j])
}
@@ -107,11 +99,16 @@ func (ksf *ksf_CM) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(ksf.minus) - 1; j >= 0; j-- {
+ b = append(b, ksf.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ksh/ksh.go b/ksh/ksh.go
index 8312dc21..eab40a04 100644
--- a/ksh/ksh.go
+++ b/ksh/ksh.go
@@ -78,32 +78,23 @@ func (ksh *ksh) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (ksh *ksh) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ksh.decimal) + len(ksh.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ksh.decimal) - 1; j >= 0; j-- {
- b = append(b, ksh.decimal[j])
- }
-
+ b = append(b, ksh.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(ksh.group) - 1; j >= 0; j-- {
b = append(b, ksh.group[j])
}
@@ -117,11 +108,16 @@ func (ksh *ksh) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(ksh.minus) - 1; j >= 0; j-- {
+ b = append(b, ksh.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ksh_DE/ksh_DE.go b/ksh_DE/ksh_DE.go
index b8e8e033..51085499 100644
--- a/ksh_DE/ksh_DE.go
+++ b/ksh_DE/ksh_DE.go
@@ -78,32 +78,23 @@ func (ksh *ksh_DE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (ksh *ksh_DE) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ksh.decimal) + len(ksh.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ksh.decimal) - 1; j >= 0; j-- {
- b = append(b, ksh.decimal[j])
- }
-
+ b = append(b, ksh.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(ksh.group) - 1; j >= 0; j-- {
b = append(b, ksh.group[j])
}
@@ -117,11 +108,16 @@ func (ksh *ksh_DE) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(ksh.minus) - 1; j >= 0; j-- {
+ b = append(b, ksh.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/kw/kw.go b/kw/kw.go
index f3f4db54..74449e2f 100644
--- a/kw/kw.go
+++ b/kw/kw.go
@@ -78,8 +78,6 @@ func (kw *kw) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (kw *kw) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/kw_GB/kw_GB.go b/kw_GB/kw_GB.go
index fea3fb7a..4a5b336e 100644
--- a/kw_GB/kw_GB.go
+++ b/kw_GB/kw_GB.go
@@ -78,8 +78,6 @@ func (kw *kw_GB) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (kw *kw_GB) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/ky/ky.go b/ky/ky.go
index 5d43a1b0..28c13a0f 100644
--- a/ky/ky.go
+++ b/ky/ky.go
@@ -87,32 +87,23 @@ func (ky *ky) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (ky *ky) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ky.decimal) + len(ky.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ky.decimal) - 1; j >= 0; j-- {
- b = append(b, ky.decimal[j])
- }
-
+ b = append(b, ky.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(ky.group) - 1; j >= 0; j-- {
b = append(b, ky.group[j])
}
@@ -126,11 +117,14 @@ func (ky *ky) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, ky.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ky_KG/ky_KG.go b/ky_KG/ky_KG.go
index d500f863..6068f668 100644
--- a/ky_KG/ky_KG.go
+++ b/ky_KG/ky_KG.go
@@ -87,32 +87,23 @@ func (ky *ky_KG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ky *ky_KG) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ky.decimal) + len(ky.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ky.decimal) - 1; j >= 0; j-- {
- b = append(b, ky.decimal[j])
- }
-
+ b = append(b, ky.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(ky.group) - 1; j >= 0; j-- {
b = append(b, ky.group[j])
}
@@ -126,11 +117,14 @@ func (ky *ky_KG) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, ky.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/lag/lag.go b/lag/lag.go
index 1c5f6f82..2d271b37 100644
--- a/lag/lag.go
+++ b/lag/lag.go
@@ -79,8 +79,6 @@ func (lag *lag) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (lag *lag) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/lag_TZ/lag_TZ.go b/lag_TZ/lag_TZ.go
index 2eb63a48..6f6318c7 100644
--- a/lag_TZ/lag_TZ.go
+++ b/lag_TZ/lag_TZ.go
@@ -79,8 +79,6 @@ func (lag *lag_TZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (lag *lag_TZ) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/lb/lb.go b/lb/lb.go
index d8c0aa5e..13203c06 100644
--- a/lb/lb.go
+++ b/lb/lb.go
@@ -76,36 +76,24 @@ func (lb *lb) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (lb *lb) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(lb.decimal) + len(lb.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(lb.decimal) - 1; j >= 0; j-- {
- b = append(b, lb.decimal[j])
- }
-
+ b = append(b, lb.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(lb.group) - 1; j >= 0; j-- {
- b = append(b, lb.group[j])
- }
-
+ b = append(b, lb.group[0])
count = 1
} else {
count++
@@ -115,11 +103,14 @@ func (lb *lb) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, lb.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/lb_LU/lb_LU.go b/lb_LU/lb_LU.go
index eb57d7ea..d7469ad2 100644
--- a/lb_LU/lb_LU.go
+++ b/lb_LU/lb_LU.go
@@ -76,36 +76,24 @@ func (lb *lb_LU) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (lb *lb_LU) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(lb.decimal) + len(lb.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(lb.decimal) - 1; j >= 0; j-- {
- b = append(b, lb.decimal[j])
- }
-
+ b = append(b, lb.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(lb.group) - 1; j >= 0; j-- {
- b = append(b, lb.group[j])
- }
-
+ b = append(b, lb.group[0])
count = 1
} else {
count++
@@ -115,11 +103,14 @@ func (lb *lb_LU) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, lb.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/lg/lg.go b/lg/lg.go
index cd46c683..fca73bea 100644
--- a/lg/lg.go
+++ b/lg/lg.go
@@ -76,8 +76,6 @@ func (lg *lg) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (lg *lg) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/lg_UG/lg_UG.go b/lg_UG/lg_UG.go
index 362b9a4d..6aef1004 100644
--- a/lg_UG/lg_UG.go
+++ b/lg_UG/lg_UG.go
@@ -76,8 +76,6 @@ func (lg *lg_UG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (lg *lg_UG) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/lkt/lkt.go b/lkt/lkt.go
index add58fb1..29b141a0 100644
--- a/lkt/lkt.go
+++ b/lkt/lkt.go
@@ -1,6 +1,7 @@
package lkt
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,8 +69,6 @@ func (lkt *lkt) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (lkt *lkt) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/lkt_US/lkt_US.go b/lkt_US/lkt_US.go
index c7182904..5f6e3f34 100644
--- a/lkt_US/lkt_US.go
+++ b/lkt_US/lkt_US.go
@@ -1,6 +1,7 @@
package lkt_US
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,8 +69,6 @@ func (lkt *lkt_US) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (lkt *lkt_US) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/ln/ln.go b/ln/ln.go
index 433b95c2..e8194ebd 100644
--- a/ln/ln.go
+++ b/ln/ln.go
@@ -76,36 +76,24 @@ func (ln *ln) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (ln *ln) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ln.decimal) + len(ln.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ln.decimal) - 1; j >= 0; j-- {
- b = append(b, ln.decimal[j])
- }
-
+ b = append(b, ln.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(ln.group) - 1; j >= 0; j-- {
- b = append(b, ln.group[j])
- }
-
+ b = append(b, ln.group[0])
count = 1
} else {
count++
@@ -115,11 +103,14 @@ func (ln *ln) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, ln.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ln_AO/ln_AO.go b/ln_AO/ln_AO.go
index 3a208782..8a6c40ad 100644
--- a/ln_AO/ln_AO.go
+++ b/ln_AO/ln_AO.go
@@ -76,36 +76,24 @@ func (ln *ln_AO) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ln *ln_AO) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ln.decimal) + len(ln.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ln.decimal) - 1; j >= 0; j-- {
- b = append(b, ln.decimal[j])
- }
-
+ b = append(b, ln.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(ln.group) - 1; j >= 0; j-- {
- b = append(b, ln.group[j])
- }
-
+ b = append(b, ln.group[0])
count = 1
} else {
count++
@@ -115,11 +103,14 @@ func (ln *ln_AO) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, ln.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ln_CD/ln_CD.go b/ln_CD/ln_CD.go
index 16ce9ed3..1abe740c 100644
--- a/ln_CD/ln_CD.go
+++ b/ln_CD/ln_CD.go
@@ -76,36 +76,24 @@ func (ln *ln_CD) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ln *ln_CD) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ln.decimal) + len(ln.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ln.decimal) - 1; j >= 0; j-- {
- b = append(b, ln.decimal[j])
- }
-
+ b = append(b, ln.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(ln.group) - 1; j >= 0; j-- {
- b = append(b, ln.group[j])
- }
-
+ b = append(b, ln.group[0])
count = 1
} else {
count++
@@ -115,11 +103,14 @@ func (ln *ln_CD) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, ln.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ln_CF/ln_CF.go b/ln_CF/ln_CF.go
index bd5b35e9..802cb9e8 100644
--- a/ln_CF/ln_CF.go
+++ b/ln_CF/ln_CF.go
@@ -76,36 +76,24 @@ func (ln *ln_CF) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ln *ln_CF) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ln.decimal) + len(ln.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ln.decimal) - 1; j >= 0; j-- {
- b = append(b, ln.decimal[j])
- }
-
+ b = append(b, ln.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(ln.group) - 1; j >= 0; j-- {
- b = append(b, ln.group[j])
- }
-
+ b = append(b, ln.group[0])
count = 1
} else {
count++
@@ -115,11 +103,14 @@ func (ln *ln_CF) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, ln.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ln_CG/ln_CG.go b/ln_CG/ln_CG.go
index 54d0b1c9..a2171b61 100644
--- a/ln_CG/ln_CG.go
+++ b/ln_CG/ln_CG.go
@@ -76,36 +76,24 @@ func (ln *ln_CG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ln *ln_CG) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ln.decimal) + len(ln.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ln.decimal) - 1; j >= 0; j-- {
- b = append(b, ln.decimal[j])
- }
-
+ b = append(b, ln.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(ln.group) - 1; j >= 0; j-- {
- b = append(b, ln.group[j])
- }
-
+ b = append(b, ln.group[0])
count = 1
} else {
count++
@@ -115,11 +103,14 @@ func (ln *ln_CG) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, ln.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/lo/lo.go b/lo/lo.go
index bf32ed76..6b934d49 100644
--- a/lo/lo.go
+++ b/lo/lo.go
@@ -76,8 +76,6 @@ func (lo *lo) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (lo *lo) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/lo_LA/lo_LA.go b/lo_LA/lo_LA.go
index 3024f7ba..6675c732 100644
--- a/lo_LA/lo_LA.go
+++ b/lo_LA/lo_LA.go
@@ -76,8 +76,6 @@ func (lo *lo_LA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (lo *lo_LA) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/lrc/lrc.go b/lrc/lrc.go
index ae69b613..5ebc2838 100644
--- a/lrc/lrc.go
+++ b/lrc/lrc.go
@@ -1,6 +1,7 @@
package lrc
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,36 +69,24 @@ func (lrc *lrc) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (lrc *lrc) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(lrc.decimal) + len(lrc.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(lrc.decimal) - 1; j >= 0; j-- {
- b = append(b, lrc.decimal[j])
- }
-
+ b = append(b, lrc.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(lrc.group) - 1; j >= 0; j-- {
- b = append(b, lrc.group[j])
- }
-
+ b = append(b, lrc.group[0])
count = 1
} else {
count++
@@ -107,11 +96,14 @@ func (lrc *lrc) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, lrc.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/lrc_IQ/lrc_IQ.go b/lrc_IQ/lrc_IQ.go
index 45dbb07d..4a09c7b7 100644
--- a/lrc_IQ/lrc_IQ.go
+++ b/lrc_IQ/lrc_IQ.go
@@ -1,6 +1,7 @@
package lrc_IQ
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,36 +69,24 @@ func (lrc *lrc_IQ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (lrc *lrc_IQ) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(lrc.decimal) + len(lrc.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(lrc.decimal) - 1; j >= 0; j-- {
- b = append(b, lrc.decimal[j])
- }
-
+ b = append(b, lrc.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(lrc.group) - 1; j >= 0; j-- {
- b = append(b, lrc.group[j])
- }
-
+ b = append(b, lrc.group[0])
count = 1
} else {
count++
@@ -107,11 +96,14 @@ func (lrc *lrc_IQ) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, lrc.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/lrc_IR/lrc_IR.go b/lrc_IR/lrc_IR.go
index 4f761100..01290c04 100644
--- a/lrc_IR/lrc_IR.go
+++ b/lrc_IR/lrc_IR.go
@@ -1,6 +1,7 @@
package lrc_IR
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,36 +69,24 @@ func (lrc *lrc_IR) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (lrc *lrc_IR) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(lrc.decimal) + len(lrc.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(lrc.decimal) - 1; j >= 0; j-- {
- b = append(b, lrc.decimal[j])
- }
-
+ b = append(b, lrc.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(lrc.group) - 1; j >= 0; j-- {
- b = append(b, lrc.group[j])
- }
-
+ b = append(b, lrc.group[0])
count = 1
} else {
count++
@@ -107,11 +96,14 @@ func (lrc *lrc_IR) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, lrc.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/lt/lt.go b/lt/lt.go
index 8241482e..bf91e787 100644
--- a/lt/lt.go
+++ b/lt/lt.go
@@ -120,32 +120,23 @@ func (lt *lt) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (lt *lt) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(lt.decimal) + len(lt.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(lt.decimal) - 1; j >= 0; j-- {
- b = append(b, lt.decimal[j])
- }
-
+ b = append(b, lt.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(lt.group) - 1; j >= 0; j-- {
b = append(b, lt.group[j])
}
@@ -159,11 +150,16 @@ func (lt *lt) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(lt.minus) - 1; j >= 0; j-- {
+ b = append(b, lt.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/lt_LT/lt_LT.go b/lt_LT/lt_LT.go
index 0eae5832..8eb26c83 100644
--- a/lt_LT/lt_LT.go
+++ b/lt_LT/lt_LT.go
@@ -54,8 +54,8 @@ func (lt *lt_LT) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
n := math.Abs(num)
f := locales.F(n, v)
- nMod100 := math.Mod(n, 100)
nMod10 := math.Mod(n, 10)
+ nMod100 := math.Mod(n, 100)
if nMod10 == 1 && nMod100 < 11 && nMod100 > 19 {
return locales.PluralRuleOne
@@ -120,32 +120,23 @@ func (lt *lt_LT) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (lt *lt_LT) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(lt.decimal) + len(lt.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(lt.decimal) - 1; j >= 0; j-- {
- b = append(b, lt.decimal[j])
- }
-
+ b = append(b, lt.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(lt.group) - 1; j >= 0; j-- {
b = append(b, lt.group[j])
}
@@ -159,11 +150,16 @@ func (lt *lt_LT) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(lt.minus) - 1; j >= 0; j-- {
+ b = append(b, lt.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/lu/lu.go b/lu/lu.go
index 4c04a76a..2c37a8f5 100644
--- a/lu/lu.go
+++ b/lu/lu.go
@@ -1,6 +1,7 @@
package lu
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,36 +69,24 @@ func (lu *lu) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (lu *lu) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(lu.decimal) + len(lu.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(lu.decimal) - 1; j >= 0; j-- {
- b = append(b, lu.decimal[j])
- }
-
+ b = append(b, lu.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(lu.group) - 1; j >= 0; j-- {
- b = append(b, lu.group[j])
- }
-
+ b = append(b, lu.group[0])
count = 1
} else {
count++
@@ -107,11 +96,16 @@ func (lu *lu) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(lu.minus) - 1; j >= 0; j-- {
+ b = append(b, lu.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/lu_CD/lu_CD.go b/lu_CD/lu_CD.go
index 50f3e311..45392cee 100644
--- a/lu_CD/lu_CD.go
+++ b/lu_CD/lu_CD.go
@@ -1,6 +1,7 @@
package lu_CD
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,36 +69,24 @@ func (lu *lu_CD) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (lu *lu_CD) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(lu.decimal) + len(lu.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(lu.decimal) - 1; j >= 0; j-- {
- b = append(b, lu.decimal[j])
- }
-
+ b = append(b, lu.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(lu.group) - 1; j >= 0; j-- {
- b = append(b, lu.group[j])
- }
-
+ b = append(b, lu.group[0])
count = 1
} else {
count++
@@ -107,11 +96,16 @@ func (lu *lu_CD) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(lu.minus) - 1; j >= 0; j-- {
+ b = append(b, lu.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/luo/luo.go b/luo/luo.go
index e257d6ec..3d30e9f3 100644
--- a/luo/luo.go
+++ b/luo/luo.go
@@ -1,6 +1,7 @@
package luo
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,8 +69,6 @@ func (luo *luo) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (luo *luo) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/luo_KE/luo_KE.go b/luo_KE/luo_KE.go
index 2346ce63..450f6a41 100644
--- a/luo_KE/luo_KE.go
+++ b/luo_KE/luo_KE.go
@@ -1,6 +1,7 @@
package luo_KE
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,8 +69,6 @@ func (luo *luo_KE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (luo *luo_KE) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/luy/luy.go b/luy/luy.go
index 664cecfe..32fb00a2 100644
--- a/luy/luy.go
+++ b/luy/luy.go
@@ -1,6 +1,7 @@
package luy
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,8 +69,6 @@ func (luy *luy) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (luy *luy) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/luy_KE/luy_KE.go b/luy_KE/luy_KE.go
index 9ca9a4b1..5ee6681f 100644
--- a/luy_KE/luy_KE.go
+++ b/luy_KE/luy_KE.go
@@ -1,6 +1,7 @@
package luy_KE
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,8 +69,6 @@ func (luy *luy_KE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (luy *luy_KE) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/lv/lv.go b/lv/lv.go
index 8bdcc1ea..476a403b 100644
--- a/lv/lv.go
+++ b/lv/lv.go
@@ -54,10 +54,10 @@ func (lv *lv) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
n := math.Abs(num)
f := locales.F(n, v)
- nMod10 := math.Mod(n, 10)
nMod100 := math.Mod(n, 100)
- fMod100 := f % 100
+ nMod10 := math.Mod(n, 10)
fMod10 := f % 10
+ fMod100 := f % 100
if (nMod10 == 0) || (nMod100 >= 11 && nMod100 <= 19) || (v == 2 && fMod100 >= 11 && fMod100 <= 19) {
return locales.PluralRuleZero
@@ -106,32 +106,23 @@ func (lv *lv) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (lv *lv) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(lv.decimal) + len(lv.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(lv.decimal) - 1; j >= 0; j-- {
- b = append(b, lv.decimal[j])
- }
-
+ b = append(b, lv.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(lv.group) - 1; j >= 0; j-- {
b = append(b, lv.group[j])
}
@@ -145,11 +136,14 @@ func (lv *lv) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, lv.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/lv_LV/lv_LV.go b/lv_LV/lv_LV.go
index 3fa008e6..a7bfb154 100644
--- a/lv_LV/lv_LV.go
+++ b/lv_LV/lv_LV.go
@@ -106,32 +106,23 @@ func (lv *lv_LV) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (lv *lv_LV) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(lv.decimal) + len(lv.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(lv.decimal) - 1; j >= 0; j-- {
- b = append(b, lv.decimal[j])
- }
-
+ b = append(b, lv.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(lv.group) - 1; j >= 0; j-- {
b = append(b, lv.group[j])
}
@@ -145,11 +136,14 @@ func (lv *lv_LV) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, lv.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/mas/mas.go b/mas/mas.go
index ffea23eb..bbb7f89f 100644
--- a/mas/mas.go
+++ b/mas/mas.go
@@ -76,8 +76,6 @@ func (mas *mas) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (mas *mas) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/mas_KE/mas_KE.go b/mas_KE/mas_KE.go
index 183cb6e5..4b9ca417 100644
--- a/mas_KE/mas_KE.go
+++ b/mas_KE/mas_KE.go
@@ -76,8 +76,6 @@ func (mas *mas_KE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (mas *mas_KE) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/mas_TZ/mas_TZ.go b/mas_TZ/mas_TZ.go
index d4a2cfc8..2f61a0e3 100644
--- a/mas_TZ/mas_TZ.go
+++ b/mas_TZ/mas_TZ.go
@@ -76,8 +76,6 @@ func (mas *mas_TZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (mas *mas_TZ) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/mer/mer.go b/mer/mer.go
index ae3d489a..40725e3e 100644
--- a/mer/mer.go
+++ b/mer/mer.go
@@ -1,6 +1,7 @@
package mer
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,8 +69,6 @@ func (mer *mer) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (mer *mer) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/mer_KE/mer_KE.go b/mer_KE/mer_KE.go
index b8218ed8..38fe3dde 100644
--- a/mer_KE/mer_KE.go
+++ b/mer_KE/mer_KE.go
@@ -1,6 +1,7 @@
package mer_KE
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,8 +69,6 @@ func (mer *mer_KE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (mer *mer_KE) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/mfe/mfe.go b/mfe/mfe.go
index ea5f3224..96463559 100644
--- a/mfe/mfe.go
+++ b/mfe/mfe.go
@@ -1,6 +1,7 @@
package mfe
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,8 +69,6 @@ func (mfe *mfe) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (mfe *mfe) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/mfe_MU/mfe_MU.go b/mfe_MU/mfe_MU.go
index 4f2bf4c4..646968ac 100644
--- a/mfe_MU/mfe_MU.go
+++ b/mfe_MU/mfe_MU.go
@@ -1,6 +1,7 @@
package mfe_MU
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,8 +69,6 @@ func (mfe *mfe_MU) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (mfe *mfe_MU) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/mg/mg.go b/mg/mg.go
index e394f21a..78a6a4b1 100644
--- a/mg/mg.go
+++ b/mg/mg.go
@@ -76,8 +76,6 @@ func (mg *mg) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (mg *mg) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/mg_MG/mg_MG.go b/mg_MG/mg_MG.go
index fb505f20..34e9299c 100644
--- a/mg_MG/mg_MG.go
+++ b/mg_MG/mg_MG.go
@@ -76,8 +76,6 @@ func (mg *mg_MG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (mg *mg_MG) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/mgh/mgh.go b/mgh/mgh.go
index c812f83a..55c5b6e6 100644
--- a/mgh/mgh.go
+++ b/mgh/mgh.go
@@ -1,6 +1,7 @@
package mgh
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,8 +69,6 @@ func (mgh *mgh) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (mgh *mgh) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/mgh_MZ/mgh_MZ.go b/mgh_MZ/mgh_MZ.go
index a0a4df91..8f97615d 100644
--- a/mgh_MZ/mgh_MZ.go
+++ b/mgh_MZ/mgh_MZ.go
@@ -1,6 +1,7 @@
package mgh_MZ
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,8 +69,6 @@ func (mgh *mgh_MZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (mgh *mgh_MZ) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/mgo/mgo.go b/mgo/mgo.go
index 806e71ee..97292f0c 100644
--- a/mgo/mgo.go
+++ b/mgo/mgo.go
@@ -76,36 +76,24 @@ func (mgo *mgo) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (mgo *mgo) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(mgo.decimal) + len(mgo.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(mgo.decimal) - 1; j >= 0; j-- {
- b = append(b, mgo.decimal[j])
- }
-
+ b = append(b, mgo.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(mgo.group) - 1; j >= 0; j-- {
- b = append(b, mgo.group[j])
- }
-
+ b = append(b, mgo.group[0])
count = 1
} else {
count++
@@ -115,11 +103,14 @@ func (mgo *mgo) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, mgo.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/mgo_CM/mgo_CM.go b/mgo_CM/mgo_CM.go
index 705328d4..d8aeb560 100644
--- a/mgo_CM/mgo_CM.go
+++ b/mgo_CM/mgo_CM.go
@@ -76,36 +76,24 @@ func (mgo *mgo_CM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (mgo *mgo_CM) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(mgo.decimal) + len(mgo.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(mgo.decimal) - 1; j >= 0; j-- {
- b = append(b, mgo.decimal[j])
- }
-
+ b = append(b, mgo.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(mgo.group) - 1; j >= 0; j-- {
- b = append(b, mgo.group[j])
- }
-
+ b = append(b, mgo.group[0])
count = 1
} else {
count++
@@ -115,11 +103,14 @@ func (mgo *mgo_CM) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, mgo.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/mk/mk.go b/mk/mk.go
index 6b949c4d..106e348d 100644
--- a/mk/mk.go
+++ b/mk/mk.go
@@ -94,36 +94,24 @@ func (mk *mk) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (mk *mk) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(mk.decimal) + len(mk.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(mk.decimal) - 1; j >= 0; j-- {
- b = append(b, mk.decimal[j])
- }
-
+ b = append(b, mk.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(mk.group) - 1; j >= 0; j-- {
- b = append(b, mk.group[j])
- }
-
+ b = append(b, mk.group[0])
count = 1
} else {
count++
@@ -133,11 +121,14 @@ func (mk *mk) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, mk.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/mk_MK/mk_MK.go b/mk_MK/mk_MK.go
index db04bf59..f329688f 100644
--- a/mk_MK/mk_MK.go
+++ b/mk_MK/mk_MK.go
@@ -94,36 +94,24 @@ func (mk *mk_MK) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (mk *mk_MK) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(mk.decimal) + len(mk.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(mk.decimal) - 1; j >= 0; j-- {
- b = append(b, mk.decimal[j])
- }
-
+ b = append(b, mk.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(mk.group) - 1; j >= 0; j-- {
- b = append(b, mk.group[j])
- }
-
+ b = append(b, mk.group[0])
count = 1
} else {
count++
@@ -133,11 +121,14 @@ func (mk *mk_MK) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, mk.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ml/ml.go b/ml/ml.go
index b1198b52..3a4a1c3b 100644
--- a/ml/ml.go
+++ b/ml/ml.go
@@ -87,23 +87,19 @@ func (ml *ml) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (ml *ml) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ml.decimal) + len(ml.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
+ inSecondary := false
+ groupThreshold := 3
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ml.decimal) - 1; j >= 0; j-- {
- b = append(b, ml.decimal[j])
- }
-
+ b = append(b, ml.decimal[0])
inWhole = true
continue
@@ -111,13 +107,14 @@ func (ml *ml) FmtNumber(num float64, v uint64) []byte {
if inWhole {
- if count == 3 {
+ if count == groupThreshold {
+ b = append(b, ml.group[0])
+ count = 1
- for j := len(ml.group) - 1; j >= 0; j-- {
- b = append(b, ml.group[j])
+ if !inSecondary {
+ inSecondary = true
+ groupThreshold = 2
}
-
- count = 1
} else {
count++
}
@@ -126,11 +123,14 @@ func (ml *ml) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, ml.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ml_IN/ml_IN.go b/ml_IN/ml_IN.go
index 2c211f4e..9454f1d7 100644
--- a/ml_IN/ml_IN.go
+++ b/ml_IN/ml_IN.go
@@ -87,23 +87,19 @@ func (ml *ml_IN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ml *ml_IN) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ml.decimal) + len(ml.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
+ inSecondary := false
+ groupThreshold := 3
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ml.decimal) - 1; j >= 0; j-- {
- b = append(b, ml.decimal[j])
- }
-
+ b = append(b, ml.decimal[0])
inWhole = true
continue
@@ -111,13 +107,14 @@ func (ml *ml_IN) FmtNumber(num float64, v uint64) []byte {
if inWhole {
- if count == 3 {
+ if count == groupThreshold {
+ b = append(b, ml.group[0])
+ count = 1
- for j := len(ml.group) - 1; j >= 0; j-- {
- b = append(b, ml.group[j])
+ if !inSecondary {
+ inSecondary = true
+ groupThreshold = 2
}
-
- count = 1
} else {
count++
}
@@ -126,11 +123,14 @@ func (ml *ml_IN) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, ml.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/mn/mn.go b/mn/mn.go
index cae0a657..4bda8ea7 100644
--- a/mn/mn.go
+++ b/mn/mn.go
@@ -87,36 +87,24 @@ func (mn *mn) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (mn *mn) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(mn.decimal) + len(mn.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(mn.decimal) - 1; j >= 0; j-- {
- b = append(b, mn.decimal[j])
- }
-
+ b = append(b, mn.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(mn.group) - 1; j >= 0; j-- {
- b = append(b, mn.group[j])
- }
-
+ b = append(b, mn.group[0])
count = 1
} else {
count++
@@ -126,11 +114,14 @@ func (mn *mn) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, mn.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/mn_MN/mn_MN.go b/mn_MN/mn_MN.go
index 8eda8a50..1ad97244 100644
--- a/mn_MN/mn_MN.go
+++ b/mn_MN/mn_MN.go
@@ -87,36 +87,24 @@ func (mn *mn_MN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (mn *mn_MN) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(mn.decimal) + len(mn.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(mn.decimal) - 1; j >= 0; j-- {
- b = append(b, mn.decimal[j])
- }
-
+ b = append(b, mn.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(mn.group) - 1; j >= 0; j-- {
- b = append(b, mn.group[j])
- }
-
+ b = append(b, mn.group[0])
count = 1
} else {
count++
@@ -126,11 +114,14 @@ func (mn *mn_MN) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, mn.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/mr/mr.go b/mr/mr.go
index b58d8bd8..a0d6559e 100644
--- a/mr/mr.go
+++ b/mr/mr.go
@@ -99,23 +99,19 @@ func (mr *mr) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (mr *mr) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(mr.decimal) + len(mr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
+ inSecondary := false
+ groupThreshold := 3
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(mr.decimal) - 1; j >= 0; j-- {
- b = append(b, mr.decimal[j])
- }
-
+ b = append(b, mr.decimal[0])
inWhole = true
continue
@@ -123,13 +119,14 @@ func (mr *mr) FmtNumber(num float64, v uint64) []byte {
if inWhole {
- if count == 3 {
+ if count == groupThreshold {
+ b = append(b, mr.group[0])
+ count = 1
- for j := len(mr.group) - 1; j >= 0; j-- {
- b = append(b, mr.group[j])
+ if !inSecondary {
+ inSecondary = true
+ groupThreshold = 2
}
-
- count = 1
} else {
count++
}
@@ -138,11 +135,14 @@ func (mr *mr) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, mr.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/mr_IN/mr_IN.go b/mr_IN/mr_IN.go
index 187bffe0..0f87983f 100644
--- a/mr_IN/mr_IN.go
+++ b/mr_IN/mr_IN.go
@@ -99,23 +99,19 @@ func (mr *mr_IN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (mr *mr_IN) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(mr.decimal) + len(mr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
+ inSecondary := false
+ groupThreshold := 3
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(mr.decimal) - 1; j >= 0; j-- {
- b = append(b, mr.decimal[j])
- }
-
+ b = append(b, mr.decimal[0])
inWhole = true
continue
@@ -123,13 +119,14 @@ func (mr *mr_IN) FmtNumber(num float64, v uint64) []byte {
if inWhole {
- if count == 3 {
+ if count == groupThreshold {
+ b = append(b, mr.group[0])
+ count = 1
- for j := len(mr.group) - 1; j >= 0; j-- {
- b = append(b, mr.group[j])
+ if !inSecondary {
+ inSecondary = true
+ groupThreshold = 2
}
-
- count = 1
} else {
count++
}
@@ -138,11 +135,14 @@ func (mr *mr_IN) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, mr.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/mr_IN/mr_IN_test.go b/mr_IN/mr_IN_test.go
new file mode 100644
index 00000000..e9e802b9
--- /dev/null
+++ b/mr_IN/mr_IN_test.go
@@ -0,0 +1,32 @@
+package mr_IN
+
+import "testing"
+
+func TestGrouping(t *testing.T) {
+
+ tests := []struct {
+ num float64
+ v uint64
+ expected string
+ }{
+ {
+ num: 1123456.5643,
+ v: 2,
+ expected: "11,23,456.56",
+ },
+ }
+
+ trans := New()
+
+ for _, tt := range tests {
+ s := string(trans.FmtNumber(tt.num, tt.v))
+ if s != tt.expected {
+ t.Errorf("Expected '%s' Got '%s", tt.expected, s)
+ }
+ }
+
+ // num := float64(1123456.5643)
+
+ // s := trans.FmtNumber(num, 2)
+ // fmt.Println(string(s))
+}
diff --git a/ms/ms.go b/ms/ms.go
index 6c9feedf..fe57dd37 100644
--- a/ms/ms.go
+++ b/ms/ms.go
@@ -76,36 +76,24 @@ func (ms *ms) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (ms *ms) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ms.decimal) + len(ms.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ms.decimal) - 1; j >= 0; j-- {
- b = append(b, ms.decimal[j])
- }
-
+ b = append(b, ms.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(ms.group) - 1; j >= 0; j-- {
- b = append(b, ms.group[j])
- }
-
+ b = append(b, ms.group[0])
count = 1
} else {
count++
@@ -115,11 +103,14 @@ func (ms *ms) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, ms.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ms_BN/ms_BN.go b/ms_BN/ms_BN.go
index 46caaf96..2b4dceaa 100644
--- a/ms_BN/ms_BN.go
+++ b/ms_BN/ms_BN.go
@@ -76,36 +76,24 @@ func (ms *ms_BN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ms *ms_BN) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ms.decimal) + len(ms.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ms.decimal) - 1; j >= 0; j-- {
- b = append(b, ms.decimal[j])
- }
-
+ b = append(b, ms.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(ms.group) - 1; j >= 0; j-- {
- b = append(b, ms.group[j])
- }
-
+ b = append(b, ms.group[0])
count = 1
} else {
count++
@@ -115,11 +103,14 @@ func (ms *ms_BN) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, ms.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ms_MY/ms_MY.go b/ms_MY/ms_MY.go
index 33de25dd..0be8b447 100644
--- a/ms_MY/ms_MY.go
+++ b/ms_MY/ms_MY.go
@@ -76,36 +76,24 @@ func (ms *ms_MY) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ms *ms_MY) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ms.decimal) + len(ms.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ms.decimal) - 1; j >= 0; j-- {
- b = append(b, ms.decimal[j])
- }
-
+ b = append(b, ms.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(ms.group) - 1; j >= 0; j-- {
- b = append(b, ms.group[j])
- }
-
+ b = append(b, ms.group[0])
count = 1
} else {
count++
@@ -115,11 +103,14 @@ func (ms *ms_MY) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, ms.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ms_SG/ms_SG.go b/ms_SG/ms_SG.go
index 75dc6412..67c8992c 100644
--- a/ms_SG/ms_SG.go
+++ b/ms_SG/ms_SG.go
@@ -76,36 +76,24 @@ func (ms *ms_SG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ms *ms_SG) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ms.decimal) + len(ms.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ms.decimal) - 1; j >= 0; j-- {
- b = append(b, ms.decimal[j])
- }
-
+ b = append(b, ms.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(ms.group) - 1; j >= 0; j-- {
- b = append(b, ms.group[j])
- }
-
+ b = append(b, ms.group[0])
count = 1
} else {
count++
@@ -115,11 +103,14 @@ func (ms *ms_SG) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, ms.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/mt/mt.go b/mt/mt.go
index 9a00e4b3..a1100ac8 100644
--- a/mt/mt.go
+++ b/mt/mt.go
@@ -81,36 +81,24 @@ func (mt *mt) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (mt *mt) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(mt.decimal) + len(mt.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(mt.decimal) - 1; j >= 0; j-- {
- b = append(b, mt.decimal[j])
- }
-
+ b = append(b, mt.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(mt.group) - 1; j >= 0; j-- {
- b = append(b, mt.group[j])
- }
-
+ b = append(b, mt.group[0])
count = 1
} else {
count++
@@ -120,11 +108,14 @@ func (mt *mt) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, mt.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/mt_MT/mt_MT.go b/mt_MT/mt_MT.go
index 9c19f4d3..7d69b2c6 100644
--- a/mt_MT/mt_MT.go
+++ b/mt_MT/mt_MT.go
@@ -81,36 +81,24 @@ func (mt *mt_MT) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (mt *mt_MT) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(mt.decimal) + len(mt.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(mt.decimal) - 1; j >= 0; j-- {
- b = append(b, mt.decimal[j])
- }
-
+ b = append(b, mt.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(mt.group) - 1; j >= 0; j-- {
- b = append(b, mt.group[j])
- }
-
+ b = append(b, mt.group[0])
count = 1
} else {
count++
@@ -120,11 +108,14 @@ func (mt *mt_MT) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, mt.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/mua/mua.go b/mua/mua.go
index 4c3d4e24..642bb0c4 100644
--- a/mua/mua.go
+++ b/mua/mua.go
@@ -1,6 +1,7 @@
package mua
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,36 +69,24 @@ func (mua *mua) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (mua *mua) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(mua.decimal) + len(mua.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(mua.decimal) - 1; j >= 0; j-- {
- b = append(b, mua.decimal[j])
- }
-
+ b = append(b, mua.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(mua.group) - 1; j >= 0; j-- {
- b = append(b, mua.group[j])
- }
-
+ b = append(b, mua.group[0])
count = 1
} else {
count++
@@ -107,11 +96,16 @@ func (mua *mua) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(mua.minus) - 1; j >= 0; j-- {
+ b = append(b, mua.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/mua_CM/mua_CM.go b/mua_CM/mua_CM.go
index 68b61dd9..28f3e437 100644
--- a/mua_CM/mua_CM.go
+++ b/mua_CM/mua_CM.go
@@ -1,6 +1,7 @@
package mua_CM
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,36 +69,24 @@ func (mua *mua_CM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (mua *mua_CM) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(mua.decimal) + len(mua.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(mua.decimal) - 1; j >= 0; j-- {
- b = append(b, mua.decimal[j])
- }
-
+ b = append(b, mua.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(mua.group) - 1; j >= 0; j-- {
- b = append(b, mua.group[j])
- }
-
+ b = append(b, mua.group[0])
count = 1
} else {
count++
@@ -107,11 +96,16 @@ func (mua *mua_CM) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(mua.minus) - 1; j >= 0; j-- {
+ b = append(b, mua.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/my/my.go b/my/my.go
index 3184e13d..8a010f92 100644
--- a/my/my.go
+++ b/my/my.go
@@ -1,6 +1,7 @@
package my
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,36 +69,24 @@ func (my *my) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (my *my) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(my.decimal) + len(my.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(my.decimal) - 1; j >= 0; j-- {
- b = append(b, my.decimal[j])
- }
-
+ b = append(b, my.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(my.group) - 1; j >= 0; j-- {
- b = append(b, my.group[j])
- }
-
+ b = append(b, my.group[0])
count = 1
} else {
count++
@@ -107,11 +96,14 @@ func (my *my) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, my.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/my_MM/my_MM.go b/my_MM/my_MM.go
index fe374877..f8d4f25f 100644
--- a/my_MM/my_MM.go
+++ b/my_MM/my_MM.go
@@ -1,6 +1,7 @@
package my_MM
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,36 +69,24 @@ func (my *my_MM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (my *my_MM) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(my.decimal) + len(my.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(my.decimal) - 1; j >= 0; j-- {
- b = append(b, my.decimal[j])
- }
-
+ b = append(b, my.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(my.group) - 1; j >= 0; j-- {
- b = append(b, my.group[j])
- }
-
+ b = append(b, my.group[0])
count = 1
} else {
count++
@@ -107,11 +96,14 @@ func (my *my_MM) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, my.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/mzn/mzn.go b/mzn/mzn.go
index 3cefe91d..508457de 100644
--- a/mzn/mzn.go
+++ b/mzn/mzn.go
@@ -1,6 +1,7 @@
package mzn
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,8 +69,6 @@ func (mzn *mzn) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (mzn *mzn) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/mzn_IR/mzn_IR.go b/mzn_IR/mzn_IR.go
index 0ca86ec9..f1948b52 100644
--- a/mzn_IR/mzn_IR.go
+++ b/mzn_IR/mzn_IR.go
@@ -1,6 +1,7 @@
package mzn_IR
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,8 +69,6 @@ func (mzn *mzn_IR) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (mzn *mzn_IR) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/naq/naq.go b/naq/naq.go
index e1fa3031..a200d463 100644
--- a/naq/naq.go
+++ b/naq/naq.go
@@ -78,8 +78,6 @@ func (naq *naq) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (naq *naq) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/naq_NA/naq_NA.go b/naq_NA/naq_NA.go
index dc120c64..27b761a2 100644
--- a/naq_NA/naq_NA.go
+++ b/naq_NA/naq_NA.go
@@ -78,8 +78,6 @@ func (naq *naq_NA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (naq *naq_NA) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/nb/nb.go b/nb/nb.go
index 745d3d23..817362ad 100644
--- a/nb/nb.go
+++ b/nb/nb.go
@@ -76,19 +76,15 @@ func (nb *nb) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (nb *nb) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(nb.decimal) + len(nb.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(nb.decimal) - 1; j >= 0; j-- {
b = append(b, nb.decimal[j])
}
@@ -99,9 +95,7 @@ func (nb *nb) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(nb.group) - 1; j >= 0; j-- {
b = append(b, nb.group[j])
}
@@ -115,11 +109,16 @@ func (nb *nb) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(nb.minus) - 1; j >= 0; j-- {
+ b = append(b, nb.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/nb_NO/nb_NO.go b/nb_NO/nb_NO.go
index d14c9a73..3ac45432 100644
--- a/nb_NO/nb_NO.go
+++ b/nb_NO/nb_NO.go
@@ -76,19 +76,15 @@ func (nb *nb_NO) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (nb *nb_NO) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(nb.decimal) + len(nb.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(nb.decimal) - 1; j >= 0; j-- {
b = append(b, nb.decimal[j])
}
@@ -99,9 +95,7 @@ func (nb *nb_NO) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(nb.group) - 1; j >= 0; j-- {
b = append(b, nb.group[j])
}
@@ -115,11 +109,16 @@ func (nb *nb_NO) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(nb.minus) - 1; j >= 0; j-- {
+ b = append(b, nb.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/nb_SJ/nb_SJ.go b/nb_SJ/nb_SJ.go
index a0c1f012..131e1b04 100644
--- a/nb_SJ/nb_SJ.go
+++ b/nb_SJ/nb_SJ.go
@@ -76,19 +76,15 @@ func (nb *nb_SJ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (nb *nb_SJ) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(nb.decimal) + len(nb.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(nb.decimal) - 1; j >= 0; j-- {
b = append(b, nb.decimal[j])
}
@@ -99,9 +95,7 @@ func (nb *nb_SJ) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(nb.group) - 1; j >= 0; j-- {
b = append(b, nb.group[j])
}
@@ -115,11 +109,16 @@ func (nb *nb_SJ) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(nb.minus) - 1; j >= 0; j-- {
+ b = append(b, nb.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/nd/nd.go b/nd/nd.go
index eef7b154..07c5e1f6 100644
--- a/nd/nd.go
+++ b/nd/nd.go
@@ -76,8 +76,6 @@ func (nd *nd) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (nd *nd) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/nd_ZW/nd_ZW.go b/nd_ZW/nd_ZW.go
index 6fbdb498..36210945 100644
--- a/nd_ZW/nd_ZW.go
+++ b/nd_ZW/nd_ZW.go
@@ -76,8 +76,6 @@ func (nd *nd_ZW) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (nd *nd_ZW) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/ne/ne.go b/ne/ne.go
index 6a1893b4..06b5b1a4 100644
--- a/ne/ne.go
+++ b/ne/ne.go
@@ -94,36 +94,24 @@ func (ne *ne) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (ne *ne) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ne.decimal) + len(ne.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ne.decimal) - 1; j >= 0; j-- {
- b = append(b, ne.decimal[j])
- }
-
+ b = append(b, ne.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(ne.group) - 1; j >= 0; j-- {
- b = append(b, ne.group[j])
- }
-
+ b = append(b, ne.group[0])
count = 1
} else {
count++
@@ -133,11 +121,14 @@ func (ne *ne) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, ne.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ne_IN/ne_IN.go b/ne_IN/ne_IN.go
index 55c4fe25..8729d2e9 100644
--- a/ne_IN/ne_IN.go
+++ b/ne_IN/ne_IN.go
@@ -94,36 +94,24 @@ func (ne *ne_IN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ne *ne_IN) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ne.decimal) + len(ne.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ne.decimal) - 1; j >= 0; j-- {
- b = append(b, ne.decimal[j])
- }
-
+ b = append(b, ne.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(ne.group) - 1; j >= 0; j-- {
- b = append(b, ne.group[j])
- }
-
+ b = append(b, ne.group[0])
count = 1
} else {
count++
@@ -133,11 +121,14 @@ func (ne *ne_IN) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, ne.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ne_NP/ne_NP.go b/ne_NP/ne_NP.go
index 5a99e883..872e4152 100644
--- a/ne_NP/ne_NP.go
+++ b/ne_NP/ne_NP.go
@@ -94,36 +94,24 @@ func (ne *ne_NP) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ne *ne_NP) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ne.decimal) + len(ne.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ne.decimal) - 1; j >= 0; j-- {
- b = append(b, ne.decimal[j])
- }
-
+ b = append(b, ne.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(ne.group) - 1; j >= 0; j-- {
- b = append(b, ne.group[j])
- }
-
+ b = append(b, ne.group[0])
count = 1
} else {
count++
@@ -133,11 +121,14 @@ func (ne *ne_NP) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, ne.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/nl/nl.go b/nl/nl.go
index 1359b2bf..34410f82 100644
--- a/nl/nl.go
+++ b/nl/nl.go
@@ -88,19 +88,15 @@ func (nl *nl) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (nl *nl) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(nl.decimal) + len(nl.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(nl.decimal) - 1; j >= 0; j-- {
b = append(b, nl.decimal[j])
}
@@ -111,9 +107,7 @@ func (nl *nl) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(nl.group) - 1; j >= 0; j-- {
b = append(b, nl.group[j])
}
@@ -127,11 +121,16 @@ func (nl *nl) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(nl.minus) - 1; j >= 0; j-- {
+ b = append(b, nl.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/nl_AW/nl_AW.go b/nl_AW/nl_AW.go
index 1a0d9263..8769d324 100644
--- a/nl_AW/nl_AW.go
+++ b/nl_AW/nl_AW.go
@@ -88,19 +88,15 @@ func (nl *nl_AW) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (nl *nl_AW) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(nl.decimal) + len(nl.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(nl.decimal) - 1; j >= 0; j-- {
b = append(b, nl.decimal[j])
}
@@ -111,9 +107,7 @@ func (nl *nl_AW) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(nl.group) - 1; j >= 0; j-- {
b = append(b, nl.group[j])
}
@@ -127,11 +121,16 @@ func (nl *nl_AW) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(nl.minus) - 1; j >= 0; j-- {
+ b = append(b, nl.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/nl_BE/nl_BE.go b/nl_BE/nl_BE.go
index eb25b110..bde10e90 100644
--- a/nl_BE/nl_BE.go
+++ b/nl_BE/nl_BE.go
@@ -88,19 +88,15 @@ func (nl *nl_BE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (nl *nl_BE) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(nl.decimal) + len(nl.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(nl.decimal) - 1; j >= 0; j-- {
b = append(b, nl.decimal[j])
}
@@ -111,9 +107,7 @@ func (nl *nl_BE) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(nl.group) - 1; j >= 0; j-- {
b = append(b, nl.group[j])
}
@@ -127,11 +121,16 @@ func (nl *nl_BE) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(nl.minus) - 1; j >= 0; j-- {
+ b = append(b, nl.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/nl_BQ/nl_BQ.go b/nl_BQ/nl_BQ.go
index 263f035c..74f5e8e1 100644
--- a/nl_BQ/nl_BQ.go
+++ b/nl_BQ/nl_BQ.go
@@ -88,19 +88,15 @@ func (nl *nl_BQ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (nl *nl_BQ) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(nl.decimal) + len(nl.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(nl.decimal) - 1; j >= 0; j-- {
b = append(b, nl.decimal[j])
}
@@ -111,9 +107,7 @@ func (nl *nl_BQ) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(nl.group) - 1; j >= 0; j-- {
b = append(b, nl.group[j])
}
@@ -127,11 +121,16 @@ func (nl *nl_BQ) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(nl.minus) - 1; j >= 0; j-- {
+ b = append(b, nl.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/nl_CW/nl_CW.go b/nl_CW/nl_CW.go
index 68054715..07d66f6d 100644
--- a/nl_CW/nl_CW.go
+++ b/nl_CW/nl_CW.go
@@ -88,19 +88,15 @@ func (nl *nl_CW) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (nl *nl_CW) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(nl.decimal) + len(nl.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(nl.decimal) - 1; j >= 0; j-- {
b = append(b, nl.decimal[j])
}
@@ -111,9 +107,7 @@ func (nl *nl_CW) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(nl.group) - 1; j >= 0; j-- {
b = append(b, nl.group[j])
}
@@ -127,11 +121,16 @@ func (nl *nl_CW) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(nl.minus) - 1; j >= 0; j-- {
+ b = append(b, nl.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/nl_NL/nl_NL.go b/nl_NL/nl_NL.go
index c8d0e68f..d37a6a85 100644
--- a/nl_NL/nl_NL.go
+++ b/nl_NL/nl_NL.go
@@ -88,19 +88,15 @@ func (nl *nl_NL) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (nl *nl_NL) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(nl.decimal) + len(nl.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(nl.decimal) - 1; j >= 0; j-- {
b = append(b, nl.decimal[j])
}
@@ -111,9 +107,7 @@ func (nl *nl_NL) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(nl.group) - 1; j >= 0; j-- {
b = append(b, nl.group[j])
}
@@ -127,11 +121,16 @@ func (nl *nl_NL) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(nl.minus) - 1; j >= 0; j-- {
+ b = append(b, nl.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/nl_SR/nl_SR.go b/nl_SR/nl_SR.go
index 822b8e05..5f5372ec 100644
--- a/nl_SR/nl_SR.go
+++ b/nl_SR/nl_SR.go
@@ -88,19 +88,15 @@ func (nl *nl_SR) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (nl *nl_SR) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(nl.decimal) + len(nl.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(nl.decimal) - 1; j >= 0; j-- {
b = append(b, nl.decimal[j])
}
@@ -111,9 +107,7 @@ func (nl *nl_SR) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(nl.group) - 1; j >= 0; j-- {
b = append(b, nl.group[j])
}
@@ -127,11 +121,16 @@ func (nl *nl_SR) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(nl.minus) - 1; j >= 0; j-- {
+ b = append(b, nl.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/nl_SX/nl_SX.go b/nl_SX/nl_SX.go
index cd3d8f24..758da238 100644
--- a/nl_SX/nl_SX.go
+++ b/nl_SX/nl_SX.go
@@ -88,19 +88,15 @@ func (nl *nl_SX) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (nl *nl_SX) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(nl.decimal) + len(nl.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(nl.decimal) - 1; j >= 0; j-- {
b = append(b, nl.decimal[j])
}
@@ -111,9 +107,7 @@ func (nl *nl_SX) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(nl.group) - 1; j >= 0; j-- {
b = append(b, nl.group[j])
}
@@ -127,11 +121,16 @@ func (nl *nl_SX) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(nl.minus) - 1; j >= 0; j-- {
+ b = append(b, nl.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/nmg/nmg.go b/nmg/nmg.go
index 92e6f5d1..7f54e6e1 100644
--- a/nmg/nmg.go
+++ b/nmg/nmg.go
@@ -1,6 +1,7 @@
package nmg
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,32 +69,23 @@ func (nmg *nmg) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (nmg *nmg) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(nmg.decimal) + len(nmg.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(nmg.decimal) - 1; j >= 0; j-- {
- b = append(b, nmg.decimal[j])
- }
-
+ b = append(b, nmg.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(nmg.group) - 1; j >= 0; j-- {
b = append(b, nmg.group[j])
}
@@ -107,11 +99,16 @@ func (nmg *nmg) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(nmg.minus) - 1; j >= 0; j-- {
+ b = append(b, nmg.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/nmg_CM/nmg_CM.go b/nmg_CM/nmg_CM.go
index 0a245c56..fc1c6152 100644
--- a/nmg_CM/nmg_CM.go
+++ b/nmg_CM/nmg_CM.go
@@ -1,6 +1,7 @@
package nmg_CM
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,32 +69,23 @@ func (nmg *nmg_CM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (nmg *nmg_CM) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(nmg.decimal) + len(nmg.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(nmg.decimal) - 1; j >= 0; j-- {
- b = append(b, nmg.decimal[j])
- }
-
+ b = append(b, nmg.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(nmg.group) - 1; j >= 0; j-- {
b = append(b, nmg.group[j])
}
@@ -107,11 +99,16 @@ func (nmg *nmg_CM) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(nmg.minus) - 1; j >= 0; j-- {
+ b = append(b, nmg.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/nn/nn.go b/nn/nn.go
index 5c21c1bc..eb6368a5 100644
--- a/nn/nn.go
+++ b/nn/nn.go
@@ -76,32 +76,23 @@ func (nn *nn) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (nn *nn) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(nn.decimal) + len(nn.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(nn.decimal) - 1; j >= 0; j-- {
- b = append(b, nn.decimal[j])
- }
-
+ b = append(b, nn.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(nn.group) - 1; j >= 0; j-- {
b = append(b, nn.group[j])
}
@@ -115,11 +106,16 @@ func (nn *nn) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(nn.minus) - 1; j >= 0; j-- {
+ b = append(b, nn.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/nn_NO/nn_NO.go b/nn_NO/nn_NO.go
index be7f1cf3..d322aac2 100644
--- a/nn_NO/nn_NO.go
+++ b/nn_NO/nn_NO.go
@@ -76,32 +76,23 @@ func (nn *nn_NO) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (nn *nn_NO) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(nn.decimal) + len(nn.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(nn.decimal) - 1; j >= 0; j-- {
- b = append(b, nn.decimal[j])
- }
-
+ b = append(b, nn.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(nn.group) - 1; j >= 0; j-- {
b = append(b, nn.group[j])
}
@@ -115,11 +106,16 @@ func (nn *nn_NO) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(nn.minus) - 1; j >= 0; j-- {
+ b = append(b, nn.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/nnh/nnh.go b/nnh/nnh.go
index 73833e59..fa7e901a 100644
--- a/nnh/nnh.go
+++ b/nnh/nnh.go
@@ -76,36 +76,24 @@ func (nnh *nnh) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (nnh *nnh) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(nnh.decimal) + len(nnh.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(nnh.decimal) - 1; j >= 0; j-- {
- b = append(b, nnh.decimal[j])
- }
-
+ b = append(b, nnh.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(nnh.group) - 1; j >= 0; j-- {
- b = append(b, nnh.group[j])
- }
-
+ b = append(b, nnh.group[0])
count = 1
} else {
count++
@@ -115,11 +103,16 @@ func (nnh *nnh) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(nnh.minus) - 1; j >= 0; j-- {
+ b = append(b, nnh.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/nnh_CM/nnh_CM.go b/nnh_CM/nnh_CM.go
index f755a32a..498c8caf 100644
--- a/nnh_CM/nnh_CM.go
+++ b/nnh_CM/nnh_CM.go
@@ -76,36 +76,24 @@ func (nnh *nnh_CM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (nnh *nnh_CM) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(nnh.decimal) + len(nnh.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(nnh.decimal) - 1; j >= 0; j-- {
- b = append(b, nnh.decimal[j])
- }
-
+ b = append(b, nnh.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(nnh.group) - 1; j >= 0; j-- {
- b = append(b, nnh.group[j])
- }
-
+ b = append(b, nnh.group[0])
count = 1
} else {
count++
@@ -115,11 +103,16 @@ func (nnh *nnh_CM) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(nnh.minus) - 1; j >= 0; j-- {
+ b = append(b, nnh.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/nus/nus.go b/nus/nus.go
index b5188421..9c6eef35 100644
--- a/nus/nus.go
+++ b/nus/nus.go
@@ -1,6 +1,7 @@
package nus
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,36 +69,24 @@ func (nus *nus) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (nus *nus) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(nus.decimal) + len(nus.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(nus.decimal) - 1; j >= 0; j-- {
- b = append(b, nus.decimal[j])
- }
-
+ b = append(b, nus.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(nus.group) - 1; j >= 0; j-- {
- b = append(b, nus.group[j])
- }
-
+ b = append(b, nus.group[0])
count = 1
} else {
count++
@@ -107,11 +96,16 @@ func (nus *nus) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(nus.minus) - 1; j >= 0; j-- {
+ b = append(b, nus.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/nus_SS/nus_SS.go b/nus_SS/nus_SS.go
index dc6ad698..5b803122 100644
--- a/nus_SS/nus_SS.go
+++ b/nus_SS/nus_SS.go
@@ -1,6 +1,7 @@
package nus_SS
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,36 +69,24 @@ func (nus *nus_SS) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (nus *nus_SS) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(nus.decimal) + len(nus.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(nus.decimal) - 1; j >= 0; j-- {
- b = append(b, nus.decimal[j])
- }
-
+ b = append(b, nus.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(nus.group) - 1; j >= 0; j-- {
- b = append(b, nus.group[j])
- }
-
+ b = append(b, nus.group[0])
count = 1
} else {
count++
@@ -107,11 +96,16 @@ func (nus *nus_SS) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(nus.minus) - 1; j >= 0; j-- {
+ b = append(b, nus.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/nyn/nyn.go b/nyn/nyn.go
index 4cad5e9d..714eeb32 100644
--- a/nyn/nyn.go
+++ b/nyn/nyn.go
@@ -76,8 +76,6 @@ func (nyn *nyn) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (nyn *nyn) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/nyn_UG/nyn_UG.go b/nyn_UG/nyn_UG.go
index 68d055f2..7f9a79ba 100644
--- a/nyn_UG/nyn_UG.go
+++ b/nyn_UG/nyn_UG.go
@@ -76,8 +76,6 @@ func (nyn *nyn_UG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (nyn *nyn_UG) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/om/om.go b/om/om.go
index 3e0b740b..702b1e52 100644
--- a/om/om.go
+++ b/om/om.go
@@ -76,8 +76,6 @@ func (om *om) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (om *om) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/om_ET/om_ET.go b/om_ET/om_ET.go
index 2788293e..d9d44076 100644
--- a/om_ET/om_ET.go
+++ b/om_ET/om_ET.go
@@ -76,8 +76,6 @@ func (om *om_ET) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (om *om_ET) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/om_KE/om_KE.go b/om_KE/om_KE.go
index af4ff918..decf99b5 100644
--- a/om_KE/om_KE.go
+++ b/om_KE/om_KE.go
@@ -76,8 +76,6 @@ func (om *om_KE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (om *om_KE) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/or/or.go b/or/or.go
index 2a6d5697..2920cd3e 100644
--- a/or/or.go
+++ b/or/or.go
@@ -76,23 +76,19 @@ func (or *or) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (or *or) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(or.decimal) + len(or.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
+ inSecondary := false
+ groupThreshold := 3
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(or.decimal) - 1; j >= 0; j-- {
- b = append(b, or.decimal[j])
- }
-
+ b = append(b, or.decimal[0])
inWhole = true
continue
@@ -100,13 +96,14 @@ func (or *or) FmtNumber(num float64, v uint64) []byte {
if inWhole {
- if count == 3 {
+ if count == groupThreshold {
+ b = append(b, or.group[0])
+ count = 1
- for j := len(or.group) - 1; j >= 0; j-- {
- b = append(b, or.group[j])
+ if !inSecondary {
+ inSecondary = true
+ groupThreshold = 2
}
-
- count = 1
} else {
count++
}
@@ -115,11 +112,16 @@ func (or *or) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(or.minus) - 1; j >= 0; j-- {
+ b = append(b, or.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/or_IN/or_IN.go b/or_IN/or_IN.go
index 7c2a573f..5c72c374 100644
--- a/or_IN/or_IN.go
+++ b/or_IN/or_IN.go
@@ -76,23 +76,19 @@ func (or *or_IN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (or *or_IN) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(or.decimal) + len(or.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
+ inSecondary := false
+ groupThreshold := 3
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(or.decimal) - 1; j >= 0; j-- {
- b = append(b, or.decimal[j])
- }
-
+ b = append(b, or.decimal[0])
inWhole = true
continue
@@ -100,13 +96,14 @@ func (or *or_IN) FmtNumber(num float64, v uint64) []byte {
if inWhole {
- if count == 3 {
+ if count == groupThreshold {
+ b = append(b, or.group[0])
+ count = 1
- for j := len(or.group) - 1; j >= 0; j-- {
- b = append(b, or.group[j])
+ if !inSecondary {
+ inSecondary = true
+ groupThreshold = 2
}
-
- count = 1
} else {
count++
}
@@ -115,11 +112,16 @@ func (or *or_IN) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(or.minus) - 1; j >= 0; j-- {
+ b = append(b, or.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/os/os.go b/os/os.go
index e077eb22..e3659153 100644
--- a/os/os.go
+++ b/os/os.go
@@ -76,32 +76,23 @@ func (os *os) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (os *os) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(os.decimal) + len(os.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(os.decimal) - 1; j >= 0; j-- {
- b = append(b, os.decimal[j])
- }
-
+ b = append(b, os.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(os.group) - 1; j >= 0; j-- {
b = append(b, os.group[j])
}
@@ -115,11 +106,14 @@ func (os *os) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, os.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/os_GE/os_GE.go b/os_GE/os_GE.go
index debd33fc..72479d6a 100644
--- a/os_GE/os_GE.go
+++ b/os_GE/os_GE.go
@@ -76,32 +76,23 @@ func (os *os_GE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (os *os_GE) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(os.decimal) + len(os.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(os.decimal) - 1; j >= 0; j-- {
- b = append(b, os.decimal[j])
- }
-
+ b = append(b, os.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(os.group) - 1; j >= 0; j-- {
b = append(b, os.group[j])
}
@@ -115,11 +106,14 @@ func (os *os_GE) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, os.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/os_RU/os_RU.go b/os_RU/os_RU.go
index 3c8cd16f..c990e6b9 100644
--- a/os_RU/os_RU.go
+++ b/os_RU/os_RU.go
@@ -76,32 +76,23 @@ func (os *os_RU) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (os *os_RU) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(os.decimal) + len(os.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(os.decimal) - 1; j >= 0; j-- {
- b = append(b, os.decimal[j])
- }
-
+ b = append(b, os.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(os.group) - 1; j >= 0; j-- {
b = append(b, os.group[j])
}
@@ -115,11 +106,14 @@ func (os *os_RU) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, os.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/pa/pa.go b/pa/pa.go
index 293aaf26..386b22aa 100644
--- a/pa/pa.go
+++ b/pa/pa.go
@@ -87,19 +87,18 @@ func (pa *pa) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (pa *pa) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(pa.decimal) + len(pa.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
+ inSecondary := false
+ groupThreshold := 3
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(pa.decimal) - 1; j >= 0; j-- {
b = append(b, pa.decimal[j])
}
@@ -111,13 +110,14 @@ func (pa *pa) FmtNumber(num float64, v uint64) []byte {
if inWhole {
- if count == 3 {
+ if count == groupThreshold {
+ b = append(b, pa.group[0])
+ count = 1
- for j := len(pa.group) - 1; j >= 0; j-- {
- b = append(b, pa.group[j])
+ if !inSecondary {
+ inSecondary = true
+ groupThreshold = 2
}
-
- count = 1
} else {
count++
}
@@ -126,11 +126,14 @@ func (pa *pa) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, pa.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/pa_Arab/pa_Arab.go b/pa_Arab/pa_Arab.go
index 5e607edb..b4df7dc2 100644
--- a/pa_Arab/pa_Arab.go
+++ b/pa_Arab/pa_Arab.go
@@ -87,19 +87,18 @@ func (pa *pa_Arab) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (pa *pa_Arab) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(pa.decimal) + len(pa.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
+ inSecondary := false
+ groupThreshold := 3
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(pa.decimal) - 1; j >= 0; j-- {
b = append(b, pa.decimal[j])
}
@@ -111,13 +110,14 @@ func (pa *pa_Arab) FmtNumber(num float64, v uint64) []byte {
if inWhole {
- if count == 3 {
+ if count == groupThreshold {
+ b = append(b, pa.group[0])
+ count = 1
- for j := len(pa.group) - 1; j >= 0; j-- {
- b = append(b, pa.group[j])
+ if !inSecondary {
+ inSecondary = true
+ groupThreshold = 2
}
-
- count = 1
} else {
count++
}
@@ -126,11 +126,16 @@ func (pa *pa_Arab) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(pa.minus) - 1; j >= 0; j-- {
+ b = append(b, pa.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/pa_Arab_PK/pa_Arab_PK.go b/pa_Arab_PK/pa_Arab_PK.go
index b7894b6f..1b112484 100644
--- a/pa_Arab_PK/pa_Arab_PK.go
+++ b/pa_Arab_PK/pa_Arab_PK.go
@@ -87,19 +87,18 @@ func (pa *pa_Arab_PK) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2
// avoid allocations; otherwise just cast as string.
func (pa *pa_Arab_PK) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(pa.decimal) + len(pa.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
+ inSecondary := false
+ groupThreshold := 3
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(pa.decimal) - 1; j >= 0; j-- {
b = append(b, pa.decimal[j])
}
@@ -111,13 +110,14 @@ func (pa *pa_Arab_PK) FmtNumber(num float64, v uint64) []byte {
if inWhole {
- if count == 3 {
+ if count == groupThreshold {
+ b = append(b, pa.group[0])
+ count = 1
- for j := len(pa.group) - 1; j >= 0; j-- {
- b = append(b, pa.group[j])
+ if !inSecondary {
+ inSecondary = true
+ groupThreshold = 2
}
-
- count = 1
} else {
count++
}
@@ -126,11 +126,14 @@ func (pa *pa_Arab_PK) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, pa.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/pa_Guru/pa_Guru.go b/pa_Guru/pa_Guru.go
index 961bd4d5..bed7dd00 100644
--- a/pa_Guru/pa_Guru.go
+++ b/pa_Guru/pa_Guru.go
@@ -87,19 +87,18 @@ func (pa *pa_Guru) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (pa *pa_Guru) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(pa.decimal) + len(pa.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
+ inSecondary := false
+ groupThreshold := 3
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(pa.decimal) - 1; j >= 0; j-- {
b = append(b, pa.decimal[j])
}
@@ -111,13 +110,14 @@ func (pa *pa_Guru) FmtNumber(num float64, v uint64) []byte {
if inWhole {
- if count == 3 {
+ if count == groupThreshold {
+ b = append(b, pa.group[0])
+ count = 1
- for j := len(pa.group) - 1; j >= 0; j-- {
- b = append(b, pa.group[j])
+ if !inSecondary {
+ inSecondary = true
+ groupThreshold = 2
}
-
- count = 1
} else {
count++
}
@@ -126,11 +126,14 @@ func (pa *pa_Guru) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, pa.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/pa_Guru_IN/pa_Guru_IN.go b/pa_Guru_IN/pa_Guru_IN.go
index e36e232b..c6d654c2 100644
--- a/pa_Guru_IN/pa_Guru_IN.go
+++ b/pa_Guru_IN/pa_Guru_IN.go
@@ -87,19 +87,18 @@ func (pa *pa_Guru_IN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2
// avoid allocations; otherwise just cast as string.
func (pa *pa_Guru_IN) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(pa.decimal) + len(pa.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
+ inSecondary := false
+ groupThreshold := 3
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(pa.decimal) - 1; j >= 0; j-- {
b = append(b, pa.decimal[j])
}
@@ -111,13 +110,14 @@ func (pa *pa_Guru_IN) FmtNumber(num float64, v uint64) []byte {
if inWhole {
- if count == 3 {
+ if count == groupThreshold {
+ b = append(b, pa.group[0])
+ count = 1
- for j := len(pa.group) - 1; j >= 0; j-- {
- b = append(b, pa.group[j])
+ if !inSecondary {
+ inSecondary = true
+ groupThreshold = 2
}
-
- count = 1
} else {
count++
}
@@ -126,11 +126,14 @@ func (pa *pa_Guru_IN) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, pa.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/pl/pl.go b/pl/pl.go
index 24bb94e6..0dd0c1d2 100644
--- a/pl/pl.go
+++ b/pl/pl.go
@@ -116,32 +116,23 @@ func (pl *pl) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (pl *pl) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(pl.decimal) + len(pl.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(pl.decimal) - 1; j >= 0; j-- {
- b = append(b, pl.decimal[j])
- }
-
+ b = append(b, pl.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(pl.group) - 1; j >= 0; j-- {
b = append(b, pl.group[j])
}
@@ -155,11 +146,14 @@ func (pl *pl) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, pl.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/pl_PL/pl_PL.go b/pl_PL/pl_PL.go
index 63b94b9d..12856732 100644
--- a/pl_PL/pl_PL.go
+++ b/pl_PL/pl_PL.go
@@ -116,32 +116,23 @@ func (pl *pl_PL) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (pl *pl_PL) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(pl.decimal) + len(pl.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(pl.decimal) - 1; j >= 0; j-- {
- b = append(b, pl.decimal[j])
- }
-
+ b = append(b, pl.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(pl.group) - 1; j >= 0; j-- {
b = append(b, pl.group[j])
}
@@ -155,11 +146,14 @@ func (pl *pl_PL) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, pl.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/prg/prg.go b/prg/prg.go
index c39268be..c3b979ff 100644
--- a/prg/prg.go
+++ b/prg/prg.go
@@ -83,32 +83,23 @@ func (prg *prg) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (prg *prg) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(prg.decimal) + len(prg.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(prg.decimal) - 1; j >= 0; j-- {
- b = append(b, prg.decimal[j])
- }
-
+ b = append(b, prg.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(prg.group) - 1; j >= 0; j-- {
b = append(b, prg.group[j])
}
@@ -122,11 +113,14 @@ func (prg *prg) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, prg.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/prg_001/prg_001.go b/prg_001/prg_001.go
index ea1d9caa..5f92be53 100644
--- a/prg_001/prg_001.go
+++ b/prg_001/prg_001.go
@@ -83,32 +83,23 @@ func (prg *prg_001) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 ui
// avoid allocations; otherwise just cast as string.
func (prg *prg_001) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(prg.decimal) + len(prg.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(prg.decimal) - 1; j >= 0; j-- {
- b = append(b, prg.decimal[j])
- }
-
+ b = append(b, prg.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(prg.group) - 1; j >= 0; j-- {
b = append(b, prg.group[j])
}
@@ -122,11 +113,14 @@ func (prg *prg_001) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, prg.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ps/ps.go b/ps/ps.go
index 42ba4575..105c9888 100644
--- a/ps/ps.go
+++ b/ps/ps.go
@@ -76,8 +76,6 @@ func (ps *ps) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (ps *ps) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/ps_AF/ps_AF.go b/ps_AF/ps_AF.go
index 61f2e6a1..dc7c0346 100644
--- a/ps_AF/ps_AF.go
+++ b/ps_AF/ps_AF.go
@@ -76,8 +76,6 @@ func (ps *ps_AF) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ps *ps_AF) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/pt/pt.go b/pt/pt.go
index 621c7ebf..62fb0385 100644
--- a/pt/pt.go
+++ b/pt/pt.go
@@ -87,36 +87,24 @@ func (pt *pt) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (pt *pt) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(pt.decimal) + len(pt.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(pt.decimal) - 1; j >= 0; j-- {
- b = append(b, pt.decimal[j])
- }
-
+ b = append(b, pt.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(pt.group) - 1; j >= 0; j-- {
- b = append(b, pt.group[j])
- }
-
+ b = append(b, pt.group[0])
count = 1
} else {
count++
@@ -126,11 +114,14 @@ func (pt *pt) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, pt.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/pt_AO/pt_AO.go b/pt_AO/pt_AO.go
index a8d2e4b4..06fc6719 100644
--- a/pt_AO/pt_AO.go
+++ b/pt_AO/pt_AO.go
@@ -87,36 +87,24 @@ func (pt *pt_AO) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (pt *pt_AO) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(pt.decimal) + len(pt.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(pt.decimal) - 1; j >= 0; j-- {
- b = append(b, pt.decimal[j])
- }
-
+ b = append(b, pt.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(pt.group) - 1; j >= 0; j-- {
- b = append(b, pt.group[j])
- }
-
+ b = append(b, pt.group[0])
count = 1
} else {
count++
@@ -126,11 +114,14 @@ func (pt *pt_AO) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, pt.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/pt_BR/pt_BR.go b/pt_BR/pt_BR.go
index 21645697..79469ff9 100644
--- a/pt_BR/pt_BR.go
+++ b/pt_BR/pt_BR.go
@@ -87,36 +87,24 @@ func (pt *pt_BR) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (pt *pt_BR) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(pt.decimal) + len(pt.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(pt.decimal) - 1; j >= 0; j-- {
- b = append(b, pt.decimal[j])
- }
-
+ b = append(b, pt.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(pt.group) - 1; j >= 0; j-- {
- b = append(b, pt.group[j])
- }
-
+ b = append(b, pt.group[0])
count = 1
} else {
count++
@@ -126,11 +114,14 @@ func (pt *pt_BR) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, pt.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/pt_CH/pt_CH.go b/pt_CH/pt_CH.go
index 9e723b24..d03bfcdf 100644
--- a/pt_CH/pt_CH.go
+++ b/pt_CH/pt_CH.go
@@ -87,36 +87,24 @@ func (pt *pt_CH) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (pt *pt_CH) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(pt.decimal) + len(pt.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(pt.decimal) - 1; j >= 0; j-- {
- b = append(b, pt.decimal[j])
- }
-
+ b = append(b, pt.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(pt.group) - 1; j >= 0; j-- {
- b = append(b, pt.group[j])
- }
-
+ b = append(b, pt.group[0])
count = 1
} else {
count++
@@ -126,11 +114,14 @@ func (pt *pt_CH) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, pt.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/pt_CV/pt_CV.go b/pt_CV/pt_CV.go
index 9a0a71b1..125b5a67 100644
--- a/pt_CV/pt_CV.go
+++ b/pt_CV/pt_CV.go
@@ -87,36 +87,24 @@ func (pt *pt_CV) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (pt *pt_CV) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(pt.decimal) + len(pt.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(pt.decimal) - 1; j >= 0; j-- {
- b = append(b, pt.decimal[j])
- }
-
+ b = append(b, pt.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(pt.group) - 1; j >= 0; j-- {
- b = append(b, pt.group[j])
- }
-
+ b = append(b, pt.group[0])
count = 1
} else {
count++
@@ -126,11 +114,14 @@ func (pt *pt_CV) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, pt.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/pt_GQ/pt_GQ.go b/pt_GQ/pt_GQ.go
index 9fdad906..d974217b 100644
--- a/pt_GQ/pt_GQ.go
+++ b/pt_GQ/pt_GQ.go
@@ -87,36 +87,24 @@ func (pt *pt_GQ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (pt *pt_GQ) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(pt.decimal) + len(pt.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(pt.decimal) - 1; j >= 0; j-- {
- b = append(b, pt.decimal[j])
- }
-
+ b = append(b, pt.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(pt.group) - 1; j >= 0; j-- {
- b = append(b, pt.group[j])
- }
-
+ b = append(b, pt.group[0])
count = 1
} else {
count++
@@ -126,11 +114,14 @@ func (pt *pt_GQ) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, pt.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/pt_GW/pt_GW.go b/pt_GW/pt_GW.go
index 4a8f8693..408112ff 100644
--- a/pt_GW/pt_GW.go
+++ b/pt_GW/pt_GW.go
@@ -87,36 +87,24 @@ func (pt *pt_GW) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (pt *pt_GW) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(pt.decimal) + len(pt.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(pt.decimal) - 1; j >= 0; j-- {
- b = append(b, pt.decimal[j])
- }
-
+ b = append(b, pt.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(pt.group) - 1; j >= 0; j-- {
- b = append(b, pt.group[j])
- }
-
+ b = append(b, pt.group[0])
count = 1
} else {
count++
@@ -126,11 +114,14 @@ func (pt *pt_GW) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, pt.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/pt_LU/pt_LU.go b/pt_LU/pt_LU.go
index 0322c3ce..8cd25e55 100644
--- a/pt_LU/pt_LU.go
+++ b/pt_LU/pt_LU.go
@@ -87,36 +87,24 @@ func (pt *pt_LU) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (pt *pt_LU) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(pt.decimal) + len(pt.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(pt.decimal) - 1; j >= 0; j-- {
- b = append(b, pt.decimal[j])
- }
-
+ b = append(b, pt.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(pt.group) - 1; j >= 0; j-- {
- b = append(b, pt.group[j])
- }
-
+ b = append(b, pt.group[0])
count = 1
} else {
count++
@@ -126,11 +114,14 @@ func (pt *pt_LU) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, pt.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/pt_MO/pt_MO.go b/pt_MO/pt_MO.go
index 7c181f42..26748241 100644
--- a/pt_MO/pt_MO.go
+++ b/pt_MO/pt_MO.go
@@ -87,36 +87,24 @@ func (pt *pt_MO) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (pt *pt_MO) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(pt.decimal) + len(pt.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(pt.decimal) - 1; j >= 0; j-- {
- b = append(b, pt.decimal[j])
- }
-
+ b = append(b, pt.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(pt.group) - 1; j >= 0; j-- {
- b = append(b, pt.group[j])
- }
-
+ b = append(b, pt.group[0])
count = 1
} else {
count++
@@ -126,11 +114,14 @@ func (pt *pt_MO) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, pt.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/pt_MZ/pt_MZ.go b/pt_MZ/pt_MZ.go
index b23e4284..80fc87d2 100644
--- a/pt_MZ/pt_MZ.go
+++ b/pt_MZ/pt_MZ.go
@@ -87,36 +87,24 @@ func (pt *pt_MZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (pt *pt_MZ) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(pt.decimal) + len(pt.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(pt.decimal) - 1; j >= 0; j-- {
- b = append(b, pt.decimal[j])
- }
-
+ b = append(b, pt.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(pt.group) - 1; j >= 0; j-- {
- b = append(b, pt.group[j])
- }
-
+ b = append(b, pt.group[0])
count = 1
} else {
count++
@@ -126,11 +114,14 @@ func (pt *pt_MZ) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, pt.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/pt_PT/pt_PT.go b/pt_PT/pt_PT.go
index a5b83814..8833d6f9 100644
--- a/pt_PT/pt_PT.go
+++ b/pt_PT/pt_PT.go
@@ -87,32 +87,23 @@ func (pt *pt_PT) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (pt *pt_PT) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(pt.decimal) + len(pt.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(pt.decimal) - 1; j >= 0; j-- {
- b = append(b, pt.decimal[j])
- }
-
+ b = append(b, pt.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(pt.group) - 1; j >= 0; j-- {
b = append(b, pt.group[j])
}
@@ -126,11 +117,14 @@ func (pt *pt_PT) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, pt.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/pt_ST/pt_ST.go b/pt_ST/pt_ST.go
index db71af7b..54a67262 100644
--- a/pt_ST/pt_ST.go
+++ b/pt_ST/pt_ST.go
@@ -87,36 +87,24 @@ func (pt *pt_ST) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (pt *pt_ST) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(pt.decimal) + len(pt.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(pt.decimal) - 1; j >= 0; j-- {
- b = append(b, pt.decimal[j])
- }
-
+ b = append(b, pt.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(pt.group) - 1; j >= 0; j-- {
- b = append(b, pt.group[j])
- }
-
+ b = append(b, pt.group[0])
count = 1
} else {
count++
@@ -126,11 +114,14 @@ func (pt *pt_ST) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, pt.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/pt_TL/pt_TL.go b/pt_TL/pt_TL.go
index 13ba59f3..04312776 100644
--- a/pt_TL/pt_TL.go
+++ b/pt_TL/pt_TL.go
@@ -87,36 +87,24 @@ func (pt *pt_TL) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (pt *pt_TL) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(pt.decimal) + len(pt.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(pt.decimal) - 1; j >= 0; j-- {
- b = append(b, pt.decimal[j])
- }
-
+ b = append(b, pt.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(pt.group) - 1; j >= 0; j-- {
- b = append(b, pt.group[j])
- }
-
+ b = append(b, pt.group[0])
count = 1
} else {
count++
@@ -126,11 +114,14 @@ func (pt *pt_TL) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, pt.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/qu/qu.go b/qu/qu.go
index 33eb4793..0dfe5ef8 100644
--- a/qu/qu.go
+++ b/qu/qu.go
@@ -1,6 +1,7 @@
package qu
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,36 +69,24 @@ func (qu *qu) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (qu *qu) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(qu.decimal) + len(qu.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(qu.decimal) - 1; j >= 0; j-- {
- b = append(b, qu.decimal[j])
- }
-
+ b = append(b, qu.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(qu.group) - 1; j >= 0; j-- {
- b = append(b, qu.group[j])
- }
-
+ b = append(b, qu.group[0])
count = 1
} else {
count++
@@ -107,11 +96,14 @@ func (qu *qu) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, qu.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/qu_BO/qu_BO.go b/qu_BO/qu_BO.go
index 45456be9..d5396510 100644
--- a/qu_BO/qu_BO.go
+++ b/qu_BO/qu_BO.go
@@ -1,6 +1,7 @@
package qu_BO
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,36 +69,24 @@ func (qu *qu_BO) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (qu *qu_BO) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(qu.decimal) + len(qu.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(qu.decimal) - 1; j >= 0; j-- {
- b = append(b, qu.decimal[j])
- }
-
+ b = append(b, qu.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(qu.group) - 1; j >= 0; j-- {
- b = append(b, qu.group[j])
- }
-
+ b = append(b, qu.group[0])
count = 1
} else {
count++
@@ -107,11 +96,14 @@ func (qu *qu_BO) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, qu.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/qu_EC/qu_EC.go b/qu_EC/qu_EC.go
index 0cf751ce..3f016e8f 100644
--- a/qu_EC/qu_EC.go
+++ b/qu_EC/qu_EC.go
@@ -1,6 +1,7 @@
package qu_EC
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,36 +69,24 @@ func (qu *qu_EC) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (qu *qu_EC) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(qu.decimal) + len(qu.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(qu.decimal) - 1; j >= 0; j-- {
- b = append(b, qu.decimal[j])
- }
-
+ b = append(b, qu.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(qu.group) - 1; j >= 0; j-- {
- b = append(b, qu.group[j])
- }
-
+ b = append(b, qu.group[0])
count = 1
} else {
count++
@@ -107,11 +96,14 @@ func (qu *qu_EC) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, qu.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/qu_PE/qu_PE.go b/qu_PE/qu_PE.go
index cc101aee..48ce4aa9 100644
--- a/qu_PE/qu_PE.go
+++ b/qu_PE/qu_PE.go
@@ -1,6 +1,7 @@
package qu_PE
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,36 +69,24 @@ func (qu *qu_PE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (qu *qu_PE) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(qu.decimal) + len(qu.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(qu.decimal) - 1; j >= 0; j-- {
- b = append(b, qu.decimal[j])
- }
-
+ b = append(b, qu.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(qu.group) - 1; j >= 0; j-- {
- b = append(b, qu.group[j])
- }
-
+ b = append(b, qu.group[0])
count = 1
} else {
count++
@@ -107,11 +96,14 @@ func (qu *qu_PE) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, qu.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/rm/rm.go b/rm/rm.go
index 9ab0cd89..563af57c 100644
--- a/rm/rm.go
+++ b/rm/rm.go
@@ -76,32 +76,23 @@ func (rm *rm) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (rm *rm) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(rm.decimal) + len(rm.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(rm.decimal) - 1; j >= 0; j-- {
- b = append(b, rm.decimal[j])
- }
-
+ b = append(b, rm.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(rm.group) - 1; j >= 0; j-- {
b = append(b, rm.group[j])
}
@@ -115,11 +106,16 @@ func (rm *rm) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(rm.minus) - 1; j >= 0; j-- {
+ b = append(b, rm.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/rm_CH/rm_CH.go b/rm_CH/rm_CH.go
index 111f88e4..a8fbfb0b 100644
--- a/rm_CH/rm_CH.go
+++ b/rm_CH/rm_CH.go
@@ -76,32 +76,23 @@ func (rm *rm_CH) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (rm *rm_CH) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(rm.decimal) + len(rm.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(rm.decimal) - 1; j >= 0; j-- {
- b = append(b, rm.decimal[j])
- }
-
+ b = append(b, rm.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(rm.group) - 1; j >= 0; j-- {
b = append(b, rm.group[j])
}
@@ -115,11 +106,16 @@ func (rm *rm_CH) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(rm.minus) - 1; j >= 0; j-- {
+ b = append(b, rm.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/rn/rn.go b/rn/rn.go
index d35f3ec9..9c4962f5 100644
--- a/rn/rn.go
+++ b/rn/rn.go
@@ -1,6 +1,7 @@
package rn
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,36 +69,24 @@ func (rn *rn) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (rn *rn) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(rn.decimal) + len(rn.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(rn.decimal) - 1; j >= 0; j-- {
- b = append(b, rn.decimal[j])
- }
-
+ b = append(b, rn.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(rn.group) - 1; j >= 0; j-- {
- b = append(b, rn.group[j])
- }
-
+ b = append(b, rn.group[0])
count = 1
} else {
count++
@@ -107,11 +96,16 @@ func (rn *rn) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(rn.minus) - 1; j >= 0; j-- {
+ b = append(b, rn.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/rn_BI/rn_BI.go b/rn_BI/rn_BI.go
index eac3fdcc..bfc88028 100644
--- a/rn_BI/rn_BI.go
+++ b/rn_BI/rn_BI.go
@@ -1,6 +1,7 @@
package rn_BI
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,36 +69,24 @@ func (rn *rn_BI) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (rn *rn_BI) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(rn.decimal) + len(rn.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(rn.decimal) - 1; j >= 0; j-- {
- b = append(b, rn.decimal[j])
- }
-
+ b = append(b, rn.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(rn.group) - 1; j >= 0; j-- {
- b = append(b, rn.group[j])
- }
-
+ b = append(b, rn.group[0])
count = 1
} else {
count++
@@ -107,11 +96,16 @@ func (rn *rn_BI) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(rn.minus) - 1; j >= 0; j-- {
+ b = append(b, rn.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ro/ro.go b/ro/ro.go
index 19ea2e87..2e6e423c 100644
--- a/ro/ro.go
+++ b/ro/ro.go
@@ -106,36 +106,24 @@ func (ro *ro) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (ro *ro) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ro.decimal) + len(ro.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ro.decimal) - 1; j >= 0; j-- {
- b = append(b, ro.decimal[j])
- }
-
+ b = append(b, ro.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(ro.group) - 1; j >= 0; j-- {
- b = append(b, ro.group[j])
- }
-
+ b = append(b, ro.group[0])
count = 1
} else {
count++
@@ -145,11 +133,14 @@ func (ro *ro) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, ro.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ro_MD/ro_MD.go b/ro_MD/ro_MD.go
index 0011f813..7a7186a2 100644
--- a/ro_MD/ro_MD.go
+++ b/ro_MD/ro_MD.go
@@ -106,36 +106,24 @@ func (ro *ro_MD) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ro *ro_MD) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ro.decimal) + len(ro.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ro.decimal) - 1; j >= 0; j-- {
- b = append(b, ro.decimal[j])
- }
-
+ b = append(b, ro.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(ro.group) - 1; j >= 0; j-- {
- b = append(b, ro.group[j])
- }
-
+ b = append(b, ro.group[0])
count = 1
} else {
count++
@@ -145,11 +133,14 @@ func (ro *ro_MD) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, ro.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ro_RO/ro_RO.go b/ro_RO/ro_RO.go
index fb3a5b67..2ab0f49c 100644
--- a/ro_RO/ro_RO.go
+++ b/ro_RO/ro_RO.go
@@ -106,36 +106,24 @@ func (ro *ro_RO) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ro *ro_RO) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ro.decimal) + len(ro.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ro.decimal) - 1; j >= 0; j-- {
- b = append(b, ro.decimal[j])
- }
-
+ b = append(b, ro.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(ro.group) - 1; j >= 0; j-- {
- b = append(b, ro.group[j])
- }
-
+ b = append(b, ro.group[0])
count = 1
} else {
count++
@@ -145,11 +133,14 @@ func (ro *ro_RO) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, ro.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/rof/rof.go b/rof/rof.go
index 89440d3b..3f90e106 100644
--- a/rof/rof.go
+++ b/rof/rof.go
@@ -76,8 +76,6 @@ func (rof *rof) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (rof *rof) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/rof_TZ/rof_TZ.go b/rof_TZ/rof_TZ.go
index 8a62dd6a..31d84c99 100644
--- a/rof_TZ/rof_TZ.go
+++ b/rof_TZ/rof_TZ.go
@@ -76,8 +76,6 @@ func (rof *rof_TZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (rof *rof_TZ) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/root/root.go b/root/root.go
index f2ea5f8a..0617af29 100644
--- a/root/root.go
+++ b/root/root.go
@@ -1,6 +1,7 @@
package root
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,8 +69,6 @@ func (root *root) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint
// avoid allocations; otherwise just cast as string.
func (root *root) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/ru/ru.go b/ru/ru.go
index de8e4ac4..79319211 100644
--- a/ru/ru.go
+++ b/ru/ru.go
@@ -120,32 +120,23 @@ func (ru *ru) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (ru *ru) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ru.decimal) + len(ru.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ru.decimal) - 1; j >= 0; j-- {
- b = append(b, ru.decimal[j])
- }
-
+ b = append(b, ru.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(ru.group) - 1; j >= 0; j-- {
b = append(b, ru.group[j])
}
@@ -159,11 +150,14 @@ func (ru *ru) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, ru.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ru_BY/ru_BY.go b/ru_BY/ru_BY.go
index 29aec8a3..8b24bb87 100644
--- a/ru_BY/ru_BY.go
+++ b/ru_BY/ru_BY.go
@@ -120,32 +120,23 @@ func (ru *ru_BY) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ru *ru_BY) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ru.decimal) + len(ru.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ru.decimal) - 1; j >= 0; j-- {
- b = append(b, ru.decimal[j])
- }
-
+ b = append(b, ru.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(ru.group) - 1; j >= 0; j-- {
b = append(b, ru.group[j])
}
@@ -159,11 +150,14 @@ func (ru *ru_BY) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, ru.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ru_KG/ru_KG.go b/ru_KG/ru_KG.go
index e0f1cb93..cd14411d 100644
--- a/ru_KG/ru_KG.go
+++ b/ru_KG/ru_KG.go
@@ -120,32 +120,23 @@ func (ru *ru_KG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ru *ru_KG) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ru.decimal) + len(ru.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ru.decimal) - 1; j >= 0; j-- {
- b = append(b, ru.decimal[j])
- }
-
+ b = append(b, ru.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(ru.group) - 1; j >= 0; j-- {
b = append(b, ru.group[j])
}
@@ -159,11 +150,14 @@ func (ru *ru_KG) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, ru.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ru_KZ/ru_KZ.go b/ru_KZ/ru_KZ.go
index 4853cc4e..341b53dc 100644
--- a/ru_KZ/ru_KZ.go
+++ b/ru_KZ/ru_KZ.go
@@ -54,8 +54,8 @@ func (ru *ru_KZ) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
n := math.Abs(num)
i := int64(n)
- iMod10 := i % 10
iMod100 := i % 100
+ iMod10 := i % 10
if v == 0 && iMod10 == 1 && iMod100 != 11 {
return locales.PluralRuleOne
@@ -120,32 +120,23 @@ func (ru *ru_KZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ru *ru_KZ) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ru.decimal) + len(ru.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ru.decimal) - 1; j >= 0; j-- {
- b = append(b, ru.decimal[j])
- }
-
+ b = append(b, ru.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(ru.group) - 1; j >= 0; j-- {
b = append(b, ru.group[j])
}
@@ -159,11 +150,14 @@ func (ru *ru_KZ) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, ru.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ru_MD/ru_MD.go b/ru_MD/ru_MD.go
index 68deb5af..b10a378d 100644
--- a/ru_MD/ru_MD.go
+++ b/ru_MD/ru_MD.go
@@ -120,32 +120,23 @@ func (ru *ru_MD) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ru *ru_MD) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ru.decimal) + len(ru.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ru.decimal) - 1; j >= 0; j-- {
- b = append(b, ru.decimal[j])
- }
-
+ b = append(b, ru.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(ru.group) - 1; j >= 0; j-- {
b = append(b, ru.group[j])
}
@@ -159,11 +150,14 @@ func (ru *ru_MD) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, ru.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ru_RU/ru_RU.go b/ru_RU/ru_RU.go
index ecacc31c..6ec4147c 100644
--- a/ru_RU/ru_RU.go
+++ b/ru_RU/ru_RU.go
@@ -120,32 +120,23 @@ func (ru *ru_RU) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ru *ru_RU) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ru.decimal) + len(ru.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ru.decimal) - 1; j >= 0; j-- {
- b = append(b, ru.decimal[j])
- }
-
+ b = append(b, ru.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(ru.group) - 1; j >= 0; j-- {
b = append(b, ru.group[j])
}
@@ -159,11 +150,14 @@ func (ru *ru_RU) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, ru.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ru_UA/ru_UA.go b/ru_UA/ru_UA.go
index 10aafeeb..35c6decb 100644
--- a/ru_UA/ru_UA.go
+++ b/ru_UA/ru_UA.go
@@ -54,8 +54,8 @@ func (ru *ru_UA) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
n := math.Abs(num)
i := int64(n)
- iMod100 := i % 100
iMod10 := i % 10
+ iMod100 := i % 100
if v == 0 && iMod10 == 1 && iMod100 != 11 {
return locales.PluralRuleOne
@@ -120,32 +120,23 @@ func (ru *ru_UA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ru *ru_UA) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ru.decimal) + len(ru.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ru.decimal) - 1; j >= 0; j-- {
- b = append(b, ru.decimal[j])
- }
-
+ b = append(b, ru.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(ru.group) - 1; j >= 0; j-- {
b = append(b, ru.group[j])
}
@@ -159,11 +150,14 @@ func (ru *ru_UA) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, ru.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/rules.go b/rules.go
index 26d6f873..353f6eb3 100644
--- a/rules.go
+++ b/rules.go
@@ -56,6 +56,11 @@ type Translator interface {
// returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for locale
RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) PluralRule
+
+ // returns 'num' with digits/precision of 'v' for 'mr_IN' and handles both Whole and Real numbers based on 'v'
+ // returned as a []byte just in case the caller wishes to add more and can help
+ // avoid allocations; otherwise just cast as string.
+ FmtNumber(num float64, v uint64) []byte
}
// String returns the string value of PluralRule
diff --git a/rw/rw.go b/rw/rw.go
index 62d15592..d4240a3a 100644
--- a/rw/rw.go
+++ b/rw/rw.go
@@ -1,6 +1,7 @@
package rw
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,8 +69,6 @@ func (rw *rw) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (rw *rw) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/rw_RW/rw_RW.go b/rw_RW/rw_RW.go
index b37b2792..54b1b4c5 100644
--- a/rw_RW/rw_RW.go
+++ b/rw_RW/rw_RW.go
@@ -1,6 +1,7 @@
package rw_RW
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,8 +69,6 @@ func (rw *rw_RW) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (rw *rw_RW) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/rwk/rwk.go b/rwk/rwk.go
index d3452498..feb5c8b7 100644
--- a/rwk/rwk.go
+++ b/rwk/rwk.go
@@ -76,8 +76,6 @@ func (rwk *rwk) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (rwk *rwk) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/rwk_TZ/rwk_TZ.go b/rwk_TZ/rwk_TZ.go
index 4dfa4082..3b3be58c 100644
--- a/rwk_TZ/rwk_TZ.go
+++ b/rwk_TZ/rwk_TZ.go
@@ -76,8 +76,6 @@ func (rwk *rwk_TZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (rwk *rwk_TZ) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/sah/sah.go b/sah/sah.go
index fa275a6e..7d9ab588 100644
--- a/sah/sah.go
+++ b/sah/sah.go
@@ -1,6 +1,7 @@
package sah
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,8 +69,6 @@ func (sah *sah) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (sah *sah) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/sah_RU/sah_RU.go b/sah_RU/sah_RU.go
index c47f6a7f..8218a7cc 100644
--- a/sah_RU/sah_RU.go
+++ b/sah_RU/sah_RU.go
@@ -1,6 +1,7 @@
package sah_RU
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,8 +69,6 @@ func (sah *sah_RU) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (sah *sah_RU) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/saq/saq.go b/saq/saq.go
index 86d12905..c9042a67 100644
--- a/saq/saq.go
+++ b/saq/saq.go
@@ -76,8 +76,6 @@ func (saq *saq) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (saq *saq) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/saq_KE/saq_KE.go b/saq_KE/saq_KE.go
index 5c2644ac..471c7e00 100644
--- a/saq_KE/saq_KE.go
+++ b/saq_KE/saq_KE.go
@@ -76,8 +76,6 @@ func (saq *saq_KE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (saq *saq_KE) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/sbp/sbp.go b/sbp/sbp.go
index 9221c747..a7775cc3 100644
--- a/sbp/sbp.go
+++ b/sbp/sbp.go
@@ -1,6 +1,7 @@
package sbp
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,36 +69,24 @@ func (sbp *sbp) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (sbp *sbp) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(sbp.decimal) + len(sbp.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(sbp.decimal) - 1; j >= 0; j-- {
- b = append(b, sbp.decimal[j])
- }
-
+ b = append(b, sbp.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(sbp.group) - 1; j >= 0; j-- {
- b = append(b, sbp.group[j])
- }
-
+ b = append(b, sbp.group[0])
count = 1
} else {
count++
@@ -107,11 +96,16 @@ func (sbp *sbp) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(sbp.minus) - 1; j >= 0; j-- {
+ b = append(b, sbp.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/sbp_TZ/sbp_TZ.go b/sbp_TZ/sbp_TZ.go
index 8f8b5375..0a5c70c9 100644
--- a/sbp_TZ/sbp_TZ.go
+++ b/sbp_TZ/sbp_TZ.go
@@ -1,6 +1,7 @@
package sbp_TZ
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,36 +69,24 @@ func (sbp *sbp_TZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (sbp *sbp_TZ) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(sbp.decimal) + len(sbp.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(sbp.decimal) - 1; j >= 0; j-- {
- b = append(b, sbp.decimal[j])
- }
-
+ b = append(b, sbp.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(sbp.group) - 1; j >= 0; j-- {
- b = append(b, sbp.group[j])
- }
-
+ b = append(b, sbp.group[0])
count = 1
} else {
count++
@@ -107,11 +96,16 @@ func (sbp *sbp_TZ) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(sbp.minus) - 1; j >= 0; j-- {
+ b = append(b, sbp.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/se/se.go b/se/se.go
index 913ed589..de6be451 100644
--- a/se/se.go
+++ b/se/se.go
@@ -78,32 +78,23 @@ func (se *se) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (se *se) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(se.decimal) + len(se.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(se.decimal) - 1; j >= 0; j-- {
- b = append(b, se.decimal[j])
- }
-
+ b = append(b, se.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(se.group) - 1; j >= 0; j-- {
b = append(b, se.group[j])
}
@@ -117,11 +108,16 @@ func (se *se) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(se.minus) - 1; j >= 0; j-- {
+ b = append(b, se.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/se_FI/se_FI.go b/se_FI/se_FI.go
index d7e65be1..9089569c 100644
--- a/se_FI/se_FI.go
+++ b/se_FI/se_FI.go
@@ -78,32 +78,23 @@ func (se *se_FI) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (se *se_FI) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(se.decimal) + len(se.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(se.decimal) - 1; j >= 0; j-- {
- b = append(b, se.decimal[j])
- }
-
+ b = append(b, se.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(se.group) - 1; j >= 0; j-- {
b = append(b, se.group[j])
}
@@ -117,11 +108,16 @@ func (se *se_FI) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(se.minus) - 1; j >= 0; j-- {
+ b = append(b, se.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/se_NO/se_NO.go b/se_NO/se_NO.go
index e7900a79..2e197dc2 100644
--- a/se_NO/se_NO.go
+++ b/se_NO/se_NO.go
@@ -78,32 +78,23 @@ func (se *se_NO) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (se *se_NO) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(se.decimal) + len(se.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(se.decimal) - 1; j >= 0; j-- {
- b = append(b, se.decimal[j])
- }
-
+ b = append(b, se.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(se.group) - 1; j >= 0; j-- {
b = append(b, se.group[j])
}
@@ -117,11 +108,16 @@ func (se *se_NO) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(se.minus) - 1; j >= 0; j-- {
+ b = append(b, se.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/se_SE/se_SE.go b/se_SE/se_SE.go
index 18e2769d..2516b1d2 100644
--- a/se_SE/se_SE.go
+++ b/se_SE/se_SE.go
@@ -78,32 +78,23 @@ func (se *se_SE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (se *se_SE) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(se.decimal) + len(se.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(se.decimal) - 1; j >= 0; j-- {
- b = append(b, se.decimal[j])
- }
-
+ b = append(b, se.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(se.group) - 1; j >= 0; j-- {
b = append(b, se.group[j])
}
@@ -117,11 +108,16 @@ func (se *se_SE) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(se.minus) - 1; j >= 0; j-- {
+ b = append(b, se.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/seh/seh.go b/seh/seh.go
index 8711f9ea..9b4e967c 100644
--- a/seh/seh.go
+++ b/seh/seh.go
@@ -76,8 +76,6 @@ func (seh *seh) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (seh *seh) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/seh_MZ/seh_MZ.go b/seh_MZ/seh_MZ.go
index b40c78a5..e6274879 100644
--- a/seh_MZ/seh_MZ.go
+++ b/seh_MZ/seh_MZ.go
@@ -76,8 +76,6 @@ func (seh *seh_MZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (seh *seh_MZ) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/ses/ses.go b/ses/ses.go
index dd8708e3..870c2103 100644
--- a/ses/ses.go
+++ b/ses/ses.go
@@ -1,6 +1,7 @@
package ses
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,8 +69,6 @@ func (ses *ses) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (ses *ses) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/ses_ML/ses_ML.go b/ses_ML/ses_ML.go
index 9a94c821..86f5dffb 100644
--- a/ses_ML/ses_ML.go
+++ b/ses_ML/ses_ML.go
@@ -1,6 +1,7 @@
package ses_ML
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,8 +69,6 @@ func (ses *ses_ML) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (ses *ses_ML) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/sg/sg.go b/sg/sg.go
index b24c2d91..c5e6ea52 100644
--- a/sg/sg.go
+++ b/sg/sg.go
@@ -1,6 +1,7 @@
package sg
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,8 +69,6 @@ func (sg *sg) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (sg *sg) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/sg_CF/sg_CF.go b/sg_CF/sg_CF.go
index 177f14c5..bb1d05e1 100644
--- a/sg_CF/sg_CF.go
+++ b/sg_CF/sg_CF.go
@@ -1,6 +1,7 @@
package sg_CF
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,8 +69,6 @@ func (sg *sg_CF) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (sg *sg_CF) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/shi/shi.go b/shi/shi.go
index 67a96fa0..3daf4bba 100644
--- a/shi/shi.go
+++ b/shi/shi.go
@@ -79,8 +79,6 @@ func (shi *shi) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (shi *shi) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/shi_Latn/shi_Latn.go b/shi_Latn/shi_Latn.go
index fe0ef7ba..65d89e8a 100644
--- a/shi_Latn/shi_Latn.go
+++ b/shi_Latn/shi_Latn.go
@@ -79,8 +79,6 @@ func (shi *shi_Latn) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 u
// avoid allocations; otherwise just cast as string.
func (shi *shi_Latn) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/shi_Latn_MA/shi_Latn_MA.go b/shi_Latn_MA/shi_Latn_MA.go
index e375ddc5..d7343187 100644
--- a/shi_Latn_MA/shi_Latn_MA.go
+++ b/shi_Latn_MA/shi_Latn_MA.go
@@ -79,8 +79,6 @@ func (shi *shi_Latn_MA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v
// avoid allocations; otherwise just cast as string.
func (shi *shi_Latn_MA) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/shi_Tfng/shi_Tfng.go b/shi_Tfng/shi_Tfng.go
index 7017a131..ed413132 100644
--- a/shi_Tfng/shi_Tfng.go
+++ b/shi_Tfng/shi_Tfng.go
@@ -79,8 +79,6 @@ func (shi *shi_Tfng) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 u
// avoid allocations; otherwise just cast as string.
func (shi *shi_Tfng) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/shi_Tfng_MA/shi_Tfng_MA.go b/shi_Tfng_MA/shi_Tfng_MA.go
index 5003f0fc..18cc61ae 100644
--- a/shi_Tfng_MA/shi_Tfng_MA.go
+++ b/shi_Tfng_MA/shi_Tfng_MA.go
@@ -79,8 +79,6 @@ func (shi *shi_Tfng_MA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v
// avoid allocations; otherwise just cast as string.
func (shi *shi_Tfng_MA) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/si/si.go b/si/si.go
index bd1ad566..1e65e7ca 100644
--- a/si/si.go
+++ b/si/si.go
@@ -91,36 +91,24 @@ func (si *si) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (si *si) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(si.decimal) + len(si.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(si.decimal) - 1; j >= 0; j-- {
- b = append(b, si.decimal[j])
- }
-
+ b = append(b, si.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(si.group) - 1; j >= 0; j-- {
- b = append(b, si.group[j])
- }
-
+ b = append(b, si.group[0])
count = 1
} else {
count++
@@ -130,11 +118,14 @@ func (si *si) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, si.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/si_LK/si_LK.go b/si_LK/si_LK.go
index 12c44028..e38fa808 100644
--- a/si_LK/si_LK.go
+++ b/si_LK/si_LK.go
@@ -91,36 +91,24 @@ func (si *si_LK) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (si *si_LK) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(si.decimal) + len(si.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(si.decimal) - 1; j >= 0; j-- {
- b = append(b, si.decimal[j])
- }
-
+ b = append(b, si.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(si.group) - 1; j >= 0; j-- {
- b = append(b, si.group[j])
- }
-
+ b = append(b, si.group[0])
count = 1
} else {
count++
@@ -130,11 +118,14 @@ func (si *si_LK) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, si.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/sk/sk.go b/sk/sk.go
index fef0e79e..7ca02487 100644
--- a/sk/sk.go
+++ b/sk/sk.go
@@ -114,32 +114,23 @@ func (sk *sk) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (sk *sk) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(sk.decimal) + len(sk.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(sk.decimal) - 1; j >= 0; j-- {
- b = append(b, sk.decimal[j])
- }
-
+ b = append(b, sk.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(sk.group) - 1; j >= 0; j-- {
b = append(b, sk.group[j])
}
@@ -153,11 +144,14 @@ func (sk *sk) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, sk.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/sk_SK/sk_SK.go b/sk_SK/sk_SK.go
index 782fe841..4c535b11 100644
--- a/sk_SK/sk_SK.go
+++ b/sk_SK/sk_SK.go
@@ -114,32 +114,23 @@ func (sk *sk_SK) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (sk *sk_SK) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(sk.decimal) + len(sk.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(sk.decimal) - 1; j >= 0; j-- {
- b = append(b, sk.decimal[j])
- }
-
+ b = append(b, sk.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(sk.group) - 1; j >= 0; j-- {
b = append(b, sk.group[j])
}
@@ -153,11 +144,14 @@ func (sk *sk_SK) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, sk.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/sl/sl.go b/sl/sl.go
index 08b30634..50407051 100644
--- a/sl/sl.go
+++ b/sl/sl.go
@@ -119,36 +119,24 @@ func (sl *sl) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (sl *sl) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(sl.decimal) + len(sl.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(sl.decimal) - 1; j >= 0; j-- {
- b = append(b, sl.decimal[j])
- }
-
+ b = append(b, sl.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(sl.group) - 1; j >= 0; j-- {
- b = append(b, sl.group[j])
- }
-
+ b = append(b, sl.group[0])
count = 1
} else {
count++
@@ -158,11 +146,14 @@ func (sl *sl) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, sl.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/sl_SI/sl_SI.go b/sl_SI/sl_SI.go
index 1d9c7362..49658439 100644
--- a/sl_SI/sl_SI.go
+++ b/sl_SI/sl_SI.go
@@ -119,36 +119,24 @@ func (sl *sl_SI) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (sl *sl_SI) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(sl.decimal) + len(sl.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(sl.decimal) - 1; j >= 0; j-- {
- b = append(b, sl.decimal[j])
- }
-
+ b = append(b, sl.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(sl.group) - 1; j >= 0; j-- {
- b = append(b, sl.group[j])
- }
-
+ b = append(b, sl.group[0])
count = 1
} else {
count++
@@ -158,11 +146,14 @@ func (sl *sl_SI) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, sl.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/smn/smn.go b/smn/smn.go
index be2dec39..f29510e8 100644
--- a/smn/smn.go
+++ b/smn/smn.go
@@ -78,8 +78,6 @@ func (smn *smn) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (smn *smn) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/smn_FI/smn_FI.go b/smn_FI/smn_FI.go
index 874f6d9d..383f44b9 100644
--- a/smn_FI/smn_FI.go
+++ b/smn_FI/smn_FI.go
@@ -78,8 +78,6 @@ func (smn *smn_FI) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (smn *smn_FI) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/sn/sn.go b/sn/sn.go
index 0da35c05..8bed7a60 100644
--- a/sn/sn.go
+++ b/sn/sn.go
@@ -76,8 +76,6 @@ func (sn *sn) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (sn *sn) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/sn_ZW/sn_ZW.go b/sn_ZW/sn_ZW.go
index d0778cb6..6a348c65 100644
--- a/sn_ZW/sn_ZW.go
+++ b/sn_ZW/sn_ZW.go
@@ -76,8 +76,6 @@ func (sn *sn_ZW) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (sn *sn_ZW) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/so/so.go b/so/so.go
index b2995a22..bc65d992 100644
--- a/so/so.go
+++ b/so/so.go
@@ -76,8 +76,6 @@ func (so *so) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (so *so) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/so_DJ/so_DJ.go b/so_DJ/so_DJ.go
index e9d4daca..ceb2b23d 100644
--- a/so_DJ/so_DJ.go
+++ b/so_DJ/so_DJ.go
@@ -76,8 +76,6 @@ func (so *so_DJ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (so *so_DJ) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/so_ET/so_ET.go b/so_ET/so_ET.go
index 9b62edb5..ee87b01a 100644
--- a/so_ET/so_ET.go
+++ b/so_ET/so_ET.go
@@ -76,8 +76,6 @@ func (so *so_ET) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (so *so_ET) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/so_KE/so_KE.go b/so_KE/so_KE.go
index c69b52bf..1f14d3e4 100644
--- a/so_KE/so_KE.go
+++ b/so_KE/so_KE.go
@@ -76,8 +76,6 @@ func (so *so_KE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (so *so_KE) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/so_SO/so_SO.go b/so_SO/so_SO.go
index d48a1a36..6af55a3a 100644
--- a/so_SO/so_SO.go
+++ b/so_SO/so_SO.go
@@ -76,8 +76,6 @@ func (so *so_SO) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (so *so_SO) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/sq/sq.go b/sq/sq.go
index 9e9ca54a..adcf4223 100644
--- a/sq/sq.go
+++ b/sq/sq.go
@@ -98,32 +98,23 @@ func (sq *sq) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (sq *sq) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(sq.decimal) + len(sq.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(sq.decimal) - 1; j >= 0; j-- {
- b = append(b, sq.decimal[j])
- }
-
+ b = append(b, sq.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(sq.group) - 1; j >= 0; j-- {
b = append(b, sq.group[j])
}
@@ -137,11 +128,14 @@ func (sq *sq) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, sq.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/sq_AL/sq_AL.go b/sq_AL/sq_AL.go
index 80dc3b22..23c0054e 100644
--- a/sq_AL/sq_AL.go
+++ b/sq_AL/sq_AL.go
@@ -65,8 +65,8 @@ func (sq *sq_AL) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
func (sq *sq_AL) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
n := math.Abs(num)
- nMod100 := math.Mod(n, 100)
nMod10 := math.Mod(n, 10)
+ nMod100 := math.Mod(n, 100)
if n == 1 {
return locales.PluralRuleOne
@@ -98,32 +98,23 @@ func (sq *sq_AL) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (sq *sq_AL) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(sq.decimal) + len(sq.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(sq.decimal) - 1; j >= 0; j-- {
- b = append(b, sq.decimal[j])
- }
-
+ b = append(b, sq.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(sq.group) - 1; j >= 0; j-- {
b = append(b, sq.group[j])
}
@@ -137,11 +128,14 @@ func (sq *sq_AL) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, sq.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/sq_MK/sq_MK.go b/sq_MK/sq_MK.go
index f65a9fda..0ebabc1f 100644
--- a/sq_MK/sq_MK.go
+++ b/sq_MK/sq_MK.go
@@ -98,32 +98,23 @@ func (sq *sq_MK) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (sq *sq_MK) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(sq.decimal) + len(sq.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(sq.decimal) - 1; j >= 0; j-- {
- b = append(b, sq.decimal[j])
- }
-
+ b = append(b, sq.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(sq.group) - 1; j >= 0; j-- {
b = append(b, sq.group[j])
}
@@ -137,11 +128,14 @@ func (sq *sq_MK) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, sq.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/sq_XK/sq_XK.go b/sq_XK/sq_XK.go
index c11a3d82..0d7c39be 100644
--- a/sq_XK/sq_XK.go
+++ b/sq_XK/sq_XK.go
@@ -98,32 +98,23 @@ func (sq *sq_XK) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (sq *sq_XK) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(sq.decimal) + len(sq.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(sq.decimal) - 1; j >= 0; j-- {
- b = append(b, sq.decimal[j])
- }
-
+ b = append(b, sq.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(sq.group) - 1; j >= 0; j-- {
b = append(b, sq.group[j])
}
@@ -137,11 +128,14 @@ func (sq *sq_XK) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, sq.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/sr/sr.go b/sr/sr.go
index 64ab4db1..9970e0ef 100644
--- a/sr/sr.go
+++ b/sr/sr.go
@@ -55,8 +55,8 @@ func (sr *sr) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
n := math.Abs(num)
i := int64(n)
f := locales.F(n, v)
- iMod100 := i % 100
iMod10 := i % 10
+ iMod100 := i % 100
fMod10 := f % 10
fMod100 := f % 100
@@ -107,36 +107,24 @@ func (sr *sr) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (sr *sr) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(sr.decimal) + len(sr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(sr.decimal) - 1; j >= 0; j-- {
- b = append(b, sr.decimal[j])
- }
-
+ b = append(b, sr.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(sr.group) - 1; j >= 0; j-- {
- b = append(b, sr.group[j])
- }
-
+ b = append(b, sr.group[0])
count = 1
} else {
count++
@@ -146,11 +134,14 @@ func (sr *sr) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, sr.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/sr_Cyrl/sr_Cyrl.go b/sr_Cyrl/sr_Cyrl.go
index c3f414ad..3cc8881a 100644
--- a/sr_Cyrl/sr_Cyrl.go
+++ b/sr_Cyrl/sr_Cyrl.go
@@ -107,36 +107,24 @@ func (sr *sr_Cyrl) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (sr *sr_Cyrl) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(sr.decimal) + len(sr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(sr.decimal) - 1; j >= 0; j-- {
- b = append(b, sr.decimal[j])
- }
-
+ b = append(b, sr.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(sr.group) - 1; j >= 0; j-- {
- b = append(b, sr.group[j])
- }
-
+ b = append(b, sr.group[0])
count = 1
} else {
count++
@@ -146,11 +134,14 @@ func (sr *sr_Cyrl) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, sr.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/sr_Cyrl_BA/sr_Cyrl_BA.go b/sr_Cyrl_BA/sr_Cyrl_BA.go
index d742683c..49478d8c 100644
--- a/sr_Cyrl_BA/sr_Cyrl_BA.go
+++ b/sr_Cyrl_BA/sr_Cyrl_BA.go
@@ -107,36 +107,24 @@ func (sr *sr_Cyrl_BA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2
// avoid allocations; otherwise just cast as string.
func (sr *sr_Cyrl_BA) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(sr.decimal) + len(sr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(sr.decimal) - 1; j >= 0; j-- {
- b = append(b, sr.decimal[j])
- }
-
+ b = append(b, sr.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(sr.group) - 1; j >= 0; j-- {
- b = append(b, sr.group[j])
- }
-
+ b = append(b, sr.group[0])
count = 1
} else {
count++
@@ -146,11 +134,14 @@ func (sr *sr_Cyrl_BA) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, sr.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/sr_Cyrl_ME/sr_Cyrl_ME.go b/sr_Cyrl_ME/sr_Cyrl_ME.go
index 3c4b475c..996b0a66 100644
--- a/sr_Cyrl_ME/sr_Cyrl_ME.go
+++ b/sr_Cyrl_ME/sr_Cyrl_ME.go
@@ -107,36 +107,24 @@ func (sr *sr_Cyrl_ME) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2
// avoid allocations; otherwise just cast as string.
func (sr *sr_Cyrl_ME) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(sr.decimal) + len(sr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(sr.decimal) - 1; j >= 0; j-- {
- b = append(b, sr.decimal[j])
- }
-
+ b = append(b, sr.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(sr.group) - 1; j >= 0; j-- {
- b = append(b, sr.group[j])
- }
-
+ b = append(b, sr.group[0])
count = 1
} else {
count++
@@ -146,11 +134,14 @@ func (sr *sr_Cyrl_ME) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, sr.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/sr_Cyrl_RS/sr_Cyrl_RS.go b/sr_Cyrl_RS/sr_Cyrl_RS.go
index fd98f6be..99f7be02 100644
--- a/sr_Cyrl_RS/sr_Cyrl_RS.go
+++ b/sr_Cyrl_RS/sr_Cyrl_RS.go
@@ -107,36 +107,24 @@ func (sr *sr_Cyrl_RS) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2
// avoid allocations; otherwise just cast as string.
func (sr *sr_Cyrl_RS) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(sr.decimal) + len(sr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(sr.decimal) - 1; j >= 0; j-- {
- b = append(b, sr.decimal[j])
- }
-
+ b = append(b, sr.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(sr.group) - 1; j >= 0; j-- {
- b = append(b, sr.group[j])
- }
-
+ b = append(b, sr.group[0])
count = 1
} else {
count++
@@ -146,11 +134,14 @@ func (sr *sr_Cyrl_RS) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, sr.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/sr_Cyrl_XK/sr_Cyrl_XK.go b/sr_Cyrl_XK/sr_Cyrl_XK.go
index 0f49249b..4c1c983f 100644
--- a/sr_Cyrl_XK/sr_Cyrl_XK.go
+++ b/sr_Cyrl_XK/sr_Cyrl_XK.go
@@ -107,36 +107,24 @@ func (sr *sr_Cyrl_XK) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2
// avoid allocations; otherwise just cast as string.
func (sr *sr_Cyrl_XK) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(sr.decimal) + len(sr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(sr.decimal) - 1; j >= 0; j-- {
- b = append(b, sr.decimal[j])
- }
-
+ b = append(b, sr.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(sr.group) - 1; j >= 0; j-- {
- b = append(b, sr.group[j])
- }
-
+ b = append(b, sr.group[0])
count = 1
} else {
count++
@@ -146,11 +134,14 @@ func (sr *sr_Cyrl_XK) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, sr.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/sr_Latn/sr_Latn.go b/sr_Latn/sr_Latn.go
index f9735028..ab55c74d 100644
--- a/sr_Latn/sr_Latn.go
+++ b/sr_Latn/sr_Latn.go
@@ -55,8 +55,8 @@ func (sr *sr_Latn) CardinalPluralRule(num float64, v uint64) locales.PluralRule
n := math.Abs(num)
i := int64(n)
f := locales.F(n, v)
- iMod10 := i % 10
iMod100 := i % 100
+ iMod10 := i % 10
fMod10 := f % 10
fMod100 := f % 100
@@ -107,36 +107,24 @@ func (sr *sr_Latn) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (sr *sr_Latn) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(sr.decimal) + len(sr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(sr.decimal) - 1; j >= 0; j-- {
- b = append(b, sr.decimal[j])
- }
-
+ b = append(b, sr.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(sr.group) - 1; j >= 0; j-- {
- b = append(b, sr.group[j])
- }
-
+ b = append(b, sr.group[0])
count = 1
} else {
count++
@@ -146,11 +134,14 @@ func (sr *sr_Latn) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, sr.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/sr_Latn_BA/sr_Latn_BA.go b/sr_Latn_BA/sr_Latn_BA.go
index bd32ffea..f87f3e41 100644
--- a/sr_Latn_BA/sr_Latn_BA.go
+++ b/sr_Latn_BA/sr_Latn_BA.go
@@ -55,8 +55,8 @@ func (sr *sr_Latn_BA) CardinalPluralRule(num float64, v uint64) locales.PluralRu
n := math.Abs(num)
i := int64(n)
f := locales.F(n, v)
- iMod10 := i % 10
iMod100 := i % 100
+ iMod10 := i % 10
fMod10 := f % 10
fMod100 := f % 100
@@ -107,36 +107,24 @@ func (sr *sr_Latn_BA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2
// avoid allocations; otherwise just cast as string.
func (sr *sr_Latn_BA) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(sr.decimal) + len(sr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(sr.decimal) - 1; j >= 0; j-- {
- b = append(b, sr.decimal[j])
- }
-
+ b = append(b, sr.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(sr.group) - 1; j >= 0; j-- {
- b = append(b, sr.group[j])
- }
-
+ b = append(b, sr.group[0])
count = 1
} else {
count++
@@ -146,11 +134,14 @@ func (sr *sr_Latn_BA) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, sr.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/sr_Latn_ME/sr_Latn_ME.go b/sr_Latn_ME/sr_Latn_ME.go
index b8cd272c..ed7d6e50 100644
--- a/sr_Latn_ME/sr_Latn_ME.go
+++ b/sr_Latn_ME/sr_Latn_ME.go
@@ -107,36 +107,24 @@ func (sr *sr_Latn_ME) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2
// avoid allocations; otherwise just cast as string.
func (sr *sr_Latn_ME) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(sr.decimal) + len(sr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(sr.decimal) - 1; j >= 0; j-- {
- b = append(b, sr.decimal[j])
- }
-
+ b = append(b, sr.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(sr.group) - 1; j >= 0; j-- {
- b = append(b, sr.group[j])
- }
-
+ b = append(b, sr.group[0])
count = 1
} else {
count++
@@ -146,11 +134,14 @@ func (sr *sr_Latn_ME) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, sr.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/sr_Latn_RS/sr_Latn_RS.go b/sr_Latn_RS/sr_Latn_RS.go
index a6474b1a..1cee67c8 100644
--- a/sr_Latn_RS/sr_Latn_RS.go
+++ b/sr_Latn_RS/sr_Latn_RS.go
@@ -55,8 +55,8 @@ func (sr *sr_Latn_RS) CardinalPluralRule(num float64, v uint64) locales.PluralRu
n := math.Abs(num)
i := int64(n)
f := locales.F(n, v)
- iMod100 := i % 100
iMod10 := i % 10
+ iMod100 := i % 100
fMod10 := f % 10
fMod100 := f % 100
@@ -107,36 +107,24 @@ func (sr *sr_Latn_RS) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2
// avoid allocations; otherwise just cast as string.
func (sr *sr_Latn_RS) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(sr.decimal) + len(sr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(sr.decimal) - 1; j >= 0; j-- {
- b = append(b, sr.decimal[j])
- }
-
+ b = append(b, sr.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(sr.group) - 1; j >= 0; j-- {
- b = append(b, sr.group[j])
- }
-
+ b = append(b, sr.group[0])
count = 1
} else {
count++
@@ -146,11 +134,14 @@ func (sr *sr_Latn_RS) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, sr.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/sr_Latn_XK/sr_Latn_XK.go b/sr_Latn_XK/sr_Latn_XK.go
index c32a862d..038722a8 100644
--- a/sr_Latn_XK/sr_Latn_XK.go
+++ b/sr_Latn_XK/sr_Latn_XK.go
@@ -107,36 +107,24 @@ func (sr *sr_Latn_XK) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2
// avoid allocations; otherwise just cast as string.
func (sr *sr_Latn_XK) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(sr.decimal) + len(sr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(sr.decimal) - 1; j >= 0; j-- {
- b = append(b, sr.decimal[j])
- }
-
+ b = append(b, sr.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(sr.group) - 1; j >= 0; j-- {
- b = append(b, sr.group[j])
- }
-
+ b = append(b, sr.group[0])
count = 1
} else {
count++
@@ -146,11 +134,14 @@ func (sr *sr_Latn_XK) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, sr.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/sv/sv.go b/sv/sv.go
index 4d5329f7..5d7e3c1a 100644
--- a/sv/sv.go
+++ b/sv/sv.go
@@ -86,19 +86,15 @@ func (sv *sv) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (sv *sv) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(sv.decimal) + len(sv.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(sv.decimal) - 1; j >= 0; j-- {
b = append(b, sv.decimal[j])
}
@@ -109,9 +105,7 @@ func (sv *sv) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(sv.group) - 1; j >= 0; j-- {
b = append(b, sv.group[j])
}
@@ -125,11 +119,16 @@ func (sv *sv) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(sv.minus) - 1; j >= 0; j-- {
+ b = append(b, sv.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/sv_AX/sv_AX.go b/sv_AX/sv_AX.go
index 5e663f61..78f6f8f5 100644
--- a/sv_AX/sv_AX.go
+++ b/sv_AX/sv_AX.go
@@ -86,19 +86,15 @@ func (sv *sv_AX) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (sv *sv_AX) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(sv.decimal) + len(sv.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(sv.decimal) - 1; j >= 0; j-- {
b = append(b, sv.decimal[j])
}
@@ -109,9 +105,7 @@ func (sv *sv_AX) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(sv.group) - 1; j >= 0; j-- {
b = append(b, sv.group[j])
}
@@ -125,11 +119,16 @@ func (sv *sv_AX) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(sv.minus) - 1; j >= 0; j-- {
+ b = append(b, sv.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/sv_FI/sv_FI.go b/sv_FI/sv_FI.go
index db0145cd..c7294635 100644
--- a/sv_FI/sv_FI.go
+++ b/sv_FI/sv_FI.go
@@ -86,19 +86,15 @@ func (sv *sv_FI) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (sv *sv_FI) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(sv.decimal) + len(sv.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(sv.decimal) - 1; j >= 0; j-- {
b = append(b, sv.decimal[j])
}
@@ -109,9 +105,7 @@ func (sv *sv_FI) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(sv.group) - 1; j >= 0; j-- {
b = append(b, sv.group[j])
}
@@ -125,11 +119,16 @@ func (sv *sv_FI) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(sv.minus) - 1; j >= 0; j-- {
+ b = append(b, sv.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/sv_SE/sv_SE.go b/sv_SE/sv_SE.go
index 119ce22b..9689d395 100644
--- a/sv_SE/sv_SE.go
+++ b/sv_SE/sv_SE.go
@@ -86,19 +86,15 @@ func (sv *sv_SE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (sv *sv_SE) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(sv.decimal) + len(sv.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(sv.decimal) - 1; j >= 0; j-- {
b = append(b, sv.decimal[j])
}
@@ -109,9 +105,7 @@ func (sv *sv_SE) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(sv.group) - 1; j >= 0; j-- {
b = append(b, sv.group[j])
}
@@ -125,11 +119,16 @@ func (sv *sv_SE) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(sv.minus) - 1; j >= 0; j-- {
+ b = append(b, sv.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/sw/sw.go b/sw/sw.go
index b4debd19..04ce0442 100644
--- a/sw/sw.go
+++ b/sw/sw.go
@@ -88,36 +88,24 @@ func (sw *sw) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (sw *sw) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(sw.decimal) + len(sw.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(sw.decimal) - 1; j >= 0; j-- {
- b = append(b, sw.decimal[j])
- }
-
+ b = append(b, sw.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(sw.group) - 1; j >= 0; j-- {
- b = append(b, sw.group[j])
- }
-
+ b = append(b, sw.group[0])
count = 1
} else {
count++
@@ -127,11 +115,14 @@ func (sw *sw) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, sw.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/sw_CD/sw_CD.go b/sw_CD/sw_CD.go
index acf6f847..e65f1a73 100644
--- a/sw_CD/sw_CD.go
+++ b/sw_CD/sw_CD.go
@@ -88,36 +88,24 @@ func (sw *sw_CD) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (sw *sw_CD) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(sw.decimal) + len(sw.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(sw.decimal) - 1; j >= 0; j-- {
- b = append(b, sw.decimal[j])
- }
-
+ b = append(b, sw.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(sw.group) - 1; j >= 0; j-- {
- b = append(b, sw.group[j])
- }
-
+ b = append(b, sw.group[0])
count = 1
} else {
count++
@@ -127,11 +115,14 @@ func (sw *sw_CD) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, sw.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/sw_KE/sw_KE.go b/sw_KE/sw_KE.go
index 745e7f23..b3dcc6c4 100644
--- a/sw_KE/sw_KE.go
+++ b/sw_KE/sw_KE.go
@@ -88,36 +88,24 @@ func (sw *sw_KE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (sw *sw_KE) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(sw.decimal) + len(sw.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(sw.decimal) - 1; j >= 0; j-- {
- b = append(b, sw.decimal[j])
- }
-
+ b = append(b, sw.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(sw.group) - 1; j >= 0; j-- {
- b = append(b, sw.group[j])
- }
-
+ b = append(b, sw.group[0])
count = 1
} else {
count++
@@ -127,11 +115,14 @@ func (sw *sw_KE) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, sw.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/sw_TZ/sw_TZ.go b/sw_TZ/sw_TZ.go
index a4f44295..9e5960e7 100644
--- a/sw_TZ/sw_TZ.go
+++ b/sw_TZ/sw_TZ.go
@@ -88,36 +88,24 @@ func (sw *sw_TZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (sw *sw_TZ) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(sw.decimal) + len(sw.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(sw.decimal) - 1; j >= 0; j-- {
- b = append(b, sw.decimal[j])
- }
-
+ b = append(b, sw.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(sw.group) - 1; j >= 0; j-- {
- b = append(b, sw.group[j])
- }
-
+ b = append(b, sw.group[0])
count = 1
} else {
count++
@@ -127,11 +115,14 @@ func (sw *sw_TZ) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, sw.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/sw_UG/sw_UG.go b/sw_UG/sw_UG.go
index 270308f5..2b9fd578 100644
--- a/sw_UG/sw_UG.go
+++ b/sw_UG/sw_UG.go
@@ -88,36 +88,24 @@ func (sw *sw_UG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (sw *sw_UG) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(sw.decimal) + len(sw.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(sw.decimal) - 1; j >= 0; j-- {
- b = append(b, sw.decimal[j])
- }
-
+ b = append(b, sw.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(sw.group) - 1; j >= 0; j-- {
- b = append(b, sw.group[j])
- }
-
+ b = append(b, sw.group[0])
count = 1
} else {
count++
@@ -127,11 +115,14 @@ func (sw *sw_UG) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, sw.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ta/ta.go b/ta/ta.go
index 6bf04fe6..2c212d14 100644
--- a/ta/ta.go
+++ b/ta/ta.go
@@ -87,23 +87,19 @@ func (ta *ta) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (ta *ta) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ta.decimal) + len(ta.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
+ inSecondary := false
+ groupThreshold := 3
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ta.decimal) - 1; j >= 0; j-- {
- b = append(b, ta.decimal[j])
- }
-
+ b = append(b, ta.decimal[0])
inWhole = true
continue
@@ -111,13 +107,14 @@ func (ta *ta) FmtNumber(num float64, v uint64) []byte {
if inWhole {
- if count == 3 {
+ if count == groupThreshold {
+ b = append(b, ta.group[0])
+ count = 1
- for j := len(ta.group) - 1; j >= 0; j-- {
- b = append(b, ta.group[j])
+ if !inSecondary {
+ inSecondary = true
+ groupThreshold = 2
}
-
- count = 1
} else {
count++
}
@@ -126,11 +123,14 @@ func (ta *ta) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, ta.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ta_IN/ta_IN.go b/ta_IN/ta_IN.go
index 4cef84e6..d742ef4a 100644
--- a/ta_IN/ta_IN.go
+++ b/ta_IN/ta_IN.go
@@ -87,23 +87,19 @@ func (ta *ta_IN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ta *ta_IN) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ta.decimal) + len(ta.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
+ inSecondary := false
+ groupThreshold := 3
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ta.decimal) - 1; j >= 0; j-- {
- b = append(b, ta.decimal[j])
- }
-
+ b = append(b, ta.decimal[0])
inWhole = true
continue
@@ -111,13 +107,14 @@ func (ta *ta_IN) FmtNumber(num float64, v uint64) []byte {
if inWhole {
- if count == 3 {
+ if count == groupThreshold {
+ b = append(b, ta.group[0])
+ count = 1
- for j := len(ta.group) - 1; j >= 0; j-- {
- b = append(b, ta.group[j])
+ if !inSecondary {
+ inSecondary = true
+ groupThreshold = 2
}
-
- count = 1
} else {
count++
}
@@ -126,11 +123,14 @@ func (ta *ta_IN) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, ta.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ta_LK/ta_LK.go b/ta_LK/ta_LK.go
index f38eebbb..b4f862ee 100644
--- a/ta_LK/ta_LK.go
+++ b/ta_LK/ta_LK.go
@@ -87,23 +87,19 @@ func (ta *ta_LK) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ta *ta_LK) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ta.decimal) + len(ta.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
+ inSecondary := false
+ groupThreshold := 3
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ta.decimal) - 1; j >= 0; j-- {
- b = append(b, ta.decimal[j])
- }
-
+ b = append(b, ta.decimal[0])
inWhole = true
continue
@@ -111,13 +107,14 @@ func (ta *ta_LK) FmtNumber(num float64, v uint64) []byte {
if inWhole {
- if count == 3 {
+ if count == groupThreshold {
+ b = append(b, ta.group[0])
+ count = 1
- for j := len(ta.group) - 1; j >= 0; j-- {
- b = append(b, ta.group[j])
+ if !inSecondary {
+ inSecondary = true
+ groupThreshold = 2
}
-
- count = 1
} else {
count++
}
@@ -126,11 +123,14 @@ func (ta *ta_LK) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, ta.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ta_MY/ta_MY.go b/ta_MY/ta_MY.go
index 8609633e..7627d2e7 100644
--- a/ta_MY/ta_MY.go
+++ b/ta_MY/ta_MY.go
@@ -87,36 +87,24 @@ func (ta *ta_MY) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ta *ta_MY) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ta.decimal) + len(ta.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ta.decimal) - 1; j >= 0; j-- {
- b = append(b, ta.decimal[j])
- }
-
+ b = append(b, ta.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(ta.group) - 1; j >= 0; j-- {
- b = append(b, ta.group[j])
- }
-
+ b = append(b, ta.group[0])
count = 1
} else {
count++
@@ -126,11 +114,14 @@ func (ta *ta_MY) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, ta.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ta_SG/ta_SG.go b/ta_SG/ta_SG.go
index 1907bd2b..e65ac91e 100644
--- a/ta_SG/ta_SG.go
+++ b/ta_SG/ta_SG.go
@@ -87,36 +87,24 @@ func (ta *ta_SG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ta *ta_SG) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ta.decimal) + len(ta.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ta.decimal) - 1; j >= 0; j-- {
- b = append(b, ta.decimal[j])
- }
-
+ b = append(b, ta.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(ta.group) - 1; j >= 0; j-- {
- b = append(b, ta.group[j])
- }
-
+ b = append(b, ta.group[0])
count = 1
} else {
count++
@@ -126,11 +114,14 @@ func (ta *ta_SG) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, ta.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/te/te.go b/te/te.go
index 58b41510..82c7606c 100644
--- a/te/te.go
+++ b/te/te.go
@@ -87,23 +87,19 @@ func (te *te) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (te *te) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(te.decimal) + len(te.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
+ inSecondary := false
+ groupThreshold := 3
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(te.decimal) - 1; j >= 0; j-- {
- b = append(b, te.decimal[j])
- }
-
+ b = append(b, te.decimal[0])
inWhole = true
continue
@@ -111,13 +107,14 @@ func (te *te) FmtNumber(num float64, v uint64) []byte {
if inWhole {
- if count == 3 {
+ if count == groupThreshold {
+ b = append(b, te.group[0])
+ count = 1
- for j := len(te.group) - 1; j >= 0; j-- {
- b = append(b, te.group[j])
+ if !inSecondary {
+ inSecondary = true
+ groupThreshold = 2
}
-
- count = 1
} else {
count++
}
@@ -126,11 +123,14 @@ func (te *te) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, te.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/te_IN/te_IN.go b/te_IN/te_IN.go
index aea6119a..7e0b2b1e 100644
--- a/te_IN/te_IN.go
+++ b/te_IN/te_IN.go
@@ -87,23 +87,19 @@ func (te *te_IN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (te *te_IN) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(te.decimal) + len(te.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
+ inSecondary := false
+ groupThreshold := 3
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(te.decimal) - 1; j >= 0; j-- {
- b = append(b, te.decimal[j])
- }
-
+ b = append(b, te.decimal[0])
inWhole = true
continue
@@ -111,13 +107,14 @@ func (te *te_IN) FmtNumber(num float64, v uint64) []byte {
if inWhole {
- if count == 3 {
+ if count == groupThreshold {
+ b = append(b, te.group[0])
+ count = 1
- for j := len(te.group) - 1; j >= 0; j-- {
- b = append(b, te.group[j])
+ if !inSecondary {
+ inSecondary = true
+ groupThreshold = 2
}
-
- count = 1
} else {
count++
}
@@ -126,11 +123,14 @@ func (te *te_IN) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, te.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/teo/teo.go b/teo/teo.go
index 27684113..9a853d9c 100644
--- a/teo/teo.go
+++ b/teo/teo.go
@@ -76,8 +76,6 @@ func (teo *teo) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (teo *teo) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/teo_KE/teo_KE.go b/teo_KE/teo_KE.go
index 65828bae..64c3b01e 100644
--- a/teo_KE/teo_KE.go
+++ b/teo_KE/teo_KE.go
@@ -76,8 +76,6 @@ func (teo *teo_KE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (teo *teo_KE) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/teo_UG/teo_UG.go b/teo_UG/teo_UG.go
index 8e9f6bb4..e5e293a7 100644
--- a/teo_UG/teo_UG.go
+++ b/teo_UG/teo_UG.go
@@ -76,8 +76,6 @@ func (teo *teo_UG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (teo *teo_UG) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/th/th.go b/th/th.go
index 8e27303c..ed87e36e 100644
--- a/th/th.go
+++ b/th/th.go
@@ -1,6 +1,7 @@
package th
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,36 +69,24 @@ func (th *th) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (th *th) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(th.decimal) + len(th.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(th.decimal) - 1; j >= 0; j-- {
- b = append(b, th.decimal[j])
- }
-
+ b = append(b, th.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(th.group) - 1; j >= 0; j-- {
- b = append(b, th.group[j])
- }
-
+ b = append(b, th.group[0])
count = 1
} else {
count++
@@ -107,11 +96,14 @@ func (th *th) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, th.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/th_TH/th_TH.go b/th_TH/th_TH.go
index 9908398b..80660c84 100644
--- a/th_TH/th_TH.go
+++ b/th_TH/th_TH.go
@@ -1,6 +1,7 @@
package th_TH
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,36 +69,24 @@ func (th *th_TH) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (th *th_TH) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(th.decimal) + len(th.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(th.decimal) - 1; j >= 0; j-- {
- b = append(b, th.decimal[j])
- }
-
+ b = append(b, th.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(th.group) - 1; j >= 0; j-- {
- b = append(b, th.group[j])
- }
-
+ b = append(b, th.group[0])
count = 1
} else {
count++
@@ -107,11 +96,14 @@ func (th *th_TH) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, th.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ti/ti.go b/ti/ti.go
index 408d63d1..a8428a56 100644
--- a/ti/ti.go
+++ b/ti/ti.go
@@ -76,8 +76,6 @@ func (ti *ti) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (ti *ti) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/ti_ER/ti_ER.go b/ti_ER/ti_ER.go
index 69048df0..b8ff4293 100644
--- a/ti_ER/ti_ER.go
+++ b/ti_ER/ti_ER.go
@@ -76,8 +76,6 @@ func (ti *ti_ER) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ti *ti_ER) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/ti_ET/ti_ET.go b/ti_ET/ti_ET.go
index 99ca0df7..895128ef 100644
--- a/ti_ET/ti_ET.go
+++ b/ti_ET/ti_ET.go
@@ -76,8 +76,6 @@ func (ti *ti_ET) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ti *ti_ET) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/tk/tk.go b/tk/tk.go
index 0ce3404f..aef555c8 100644
--- a/tk/tk.go
+++ b/tk/tk.go
@@ -76,32 +76,23 @@ func (tk *tk) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (tk *tk) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(tk.decimal) + len(tk.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(tk.decimal) - 1; j >= 0; j-- {
- b = append(b, tk.decimal[j])
- }
-
+ b = append(b, tk.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(tk.group) - 1; j >= 0; j-- {
b = append(b, tk.group[j])
}
@@ -115,11 +106,14 @@ func (tk *tk) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, tk.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/tk_TM/tk_TM.go b/tk_TM/tk_TM.go
index 164a622d..f053b355 100644
--- a/tk_TM/tk_TM.go
+++ b/tk_TM/tk_TM.go
@@ -76,32 +76,23 @@ func (tk *tk_TM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (tk *tk_TM) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(tk.decimal) + len(tk.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(tk.decimal) - 1; j >= 0; j-- {
- b = append(b, tk.decimal[j])
- }
-
+ b = append(b, tk.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(tk.group) - 1; j >= 0; j-- {
b = append(b, tk.group[j])
}
@@ -115,11 +106,14 @@ func (tk *tk_TM) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, tk.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/to/to.go b/to/to.go
index fc13e9e8..fd0820f4 100644
--- a/to/to.go
+++ b/to/to.go
@@ -1,6 +1,7 @@
package to
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,36 +69,24 @@ func (to *to) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (to *to) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(to.decimal) + len(to.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(to.decimal) - 1; j >= 0; j-- {
- b = append(b, to.decimal[j])
- }
-
+ b = append(b, to.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(to.group) - 1; j >= 0; j-- {
- b = append(b, to.group[j])
- }
-
+ b = append(b, to.group[0])
count = 1
} else {
count++
@@ -107,11 +96,14 @@ func (to *to) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, to.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/to_TO/to_TO.go b/to_TO/to_TO.go
index 03d6c920..be7fab48 100644
--- a/to_TO/to_TO.go
+++ b/to_TO/to_TO.go
@@ -1,6 +1,7 @@
package to_TO
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,36 +69,24 @@ func (to *to_TO) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (to *to_TO) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(to.decimal) + len(to.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(to.decimal) - 1; j >= 0; j-- {
- b = append(b, to.decimal[j])
- }
-
+ b = append(b, to.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(to.group) - 1; j >= 0; j-- {
- b = append(b, to.group[j])
- }
-
+ b = append(b, to.group[0])
count = 1
} else {
count++
@@ -107,11 +96,14 @@ func (to *to_TO) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, to.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/tr/tr.go b/tr/tr.go
index 0b8c3a69..944da1be 100644
--- a/tr/tr.go
+++ b/tr/tr.go
@@ -87,36 +87,24 @@ func (tr *tr) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (tr *tr) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(tr.decimal) + len(tr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(tr.decimal) - 1; j >= 0; j-- {
- b = append(b, tr.decimal[j])
- }
-
+ b = append(b, tr.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(tr.group) - 1; j >= 0; j-- {
- b = append(b, tr.group[j])
- }
-
+ b = append(b, tr.group[0])
count = 1
} else {
count++
@@ -126,11 +114,14 @@ func (tr *tr) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, tr.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/tr_CY/tr_CY.go b/tr_CY/tr_CY.go
index 477c5b38..b96c2e9b 100644
--- a/tr_CY/tr_CY.go
+++ b/tr_CY/tr_CY.go
@@ -87,36 +87,24 @@ func (tr *tr_CY) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (tr *tr_CY) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(tr.decimal) + len(tr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(tr.decimal) - 1; j >= 0; j-- {
- b = append(b, tr.decimal[j])
- }
-
+ b = append(b, tr.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(tr.group) - 1; j >= 0; j-- {
- b = append(b, tr.group[j])
- }
-
+ b = append(b, tr.group[0])
count = 1
} else {
count++
@@ -126,11 +114,14 @@ func (tr *tr_CY) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, tr.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/tr_TR/tr_TR.go b/tr_TR/tr_TR.go
index aba54046..22da2713 100644
--- a/tr_TR/tr_TR.go
+++ b/tr_TR/tr_TR.go
@@ -87,36 +87,24 @@ func (tr *tr_TR) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (tr *tr_TR) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(tr.decimal) + len(tr.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(tr.decimal) - 1; j >= 0; j-- {
- b = append(b, tr.decimal[j])
- }
-
+ b = append(b, tr.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(tr.group) - 1; j >= 0; j-- {
- b = append(b, tr.group[j])
- }
-
+ b = append(b, tr.group[0])
count = 1
} else {
count++
@@ -126,11 +114,14 @@ func (tr *tr_TR) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, tr.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/twq/twq.go b/twq/twq.go
index ceeb562b..f4468386 100644
--- a/twq/twq.go
+++ b/twq/twq.go
@@ -1,6 +1,7 @@
package twq
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,32 +69,23 @@ func (twq *twq) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (twq *twq) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(twq.decimal) + len(twq.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(twq.decimal) - 1; j >= 0; j-- {
- b = append(b, twq.decimal[j])
- }
-
+ b = append(b, twq.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(twq.group) - 1; j >= 0; j-- {
b = append(b, twq.group[j])
}
@@ -107,11 +99,16 @@ func (twq *twq) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(twq.minus) - 1; j >= 0; j-- {
+ b = append(b, twq.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/twq_NE/twq_NE.go b/twq_NE/twq_NE.go
index a4948166..7dd38bd5 100644
--- a/twq_NE/twq_NE.go
+++ b/twq_NE/twq_NE.go
@@ -1,6 +1,7 @@
package twq_NE
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,32 +69,23 @@ func (twq *twq_NE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (twq *twq_NE) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(twq.decimal) + len(twq.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(twq.decimal) - 1; j >= 0; j-- {
- b = append(b, twq.decimal[j])
- }
-
+ b = append(b, twq.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(twq.group) - 1; j >= 0; j-- {
b = append(b, twq.group[j])
}
@@ -107,11 +99,16 @@ func (twq *twq_NE) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(twq.minus) - 1; j >= 0; j-- {
+ b = append(b, twq.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/tzm/tzm.go b/tzm/tzm.go
index eae5acae..f4cb050e 100644
--- a/tzm/tzm.go
+++ b/tzm/tzm.go
@@ -76,8 +76,6 @@ func (tzm *tzm) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (tzm *tzm) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/tzm_MA/tzm_MA.go b/tzm_MA/tzm_MA.go
index 5ab301fd..8d3ee1be 100644
--- a/tzm_MA/tzm_MA.go
+++ b/tzm_MA/tzm_MA.go
@@ -76,8 +76,6 @@ func (tzm *tzm_MA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (tzm *tzm_MA) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/ug/ug.go b/ug/ug.go
index 641f4fe6..1cbe683d 100644
--- a/ug/ug.go
+++ b/ug/ug.go
@@ -87,36 +87,24 @@ func (ug *ug) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (ug *ug) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ug.decimal) + len(ug.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ug.decimal) - 1; j >= 0; j-- {
- b = append(b, ug.decimal[j])
- }
-
+ b = append(b, ug.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(ug.group) - 1; j >= 0; j-- {
- b = append(b, ug.group[j])
- }
-
+ b = append(b, ug.group[0])
count = 1
} else {
count++
@@ -126,11 +114,14 @@ func (ug *ug) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, ug.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ug_CN/ug_CN.go b/ug_CN/ug_CN.go
index a84d8121..a9d85b8a 100644
--- a/ug_CN/ug_CN.go
+++ b/ug_CN/ug_CN.go
@@ -87,36 +87,24 @@ func (ug *ug_CN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ug *ug_CN) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ug.decimal) + len(ug.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ug.decimal) - 1; j >= 0; j-- {
- b = append(b, ug.decimal[j])
- }
-
+ b = append(b, ug.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(ug.group) - 1; j >= 0; j-- {
- b = append(b, ug.group[j])
- }
-
+ b = append(b, ug.group[0])
count = 1
} else {
count++
@@ -126,11 +114,14 @@ func (ug *ug_CN) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, ug.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/uk/uk.go b/uk/uk.go
index 69bd6538..6fd77e90 100644
--- a/uk/uk.go
+++ b/uk/uk.go
@@ -129,32 +129,23 @@ func (uk *uk) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (uk *uk) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(uk.decimal) + len(uk.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(uk.decimal) - 1; j >= 0; j-- {
- b = append(b, uk.decimal[j])
- }
-
+ b = append(b, uk.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(uk.group) - 1; j >= 0; j-- {
b = append(b, uk.group[j])
}
@@ -168,11 +159,14 @@ func (uk *uk) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, uk.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/uk_UA/uk_UA.go b/uk_UA/uk_UA.go
index 337309c9..274bbe33 100644
--- a/uk_UA/uk_UA.go
+++ b/uk_UA/uk_UA.go
@@ -129,32 +129,23 @@ func (uk *uk_UA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (uk *uk_UA) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(uk.decimal) + len(uk.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(uk.decimal) - 1; j >= 0; j-- {
- b = append(b, uk.decimal[j])
- }
-
+ b = append(b, uk.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(uk.group) - 1; j >= 0; j-- {
b = append(b, uk.group[j])
}
@@ -168,11 +159,14 @@ func (uk *uk_UA) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, uk.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ur/ur.go b/ur/ur.go
index bfc55304..736295a5 100644
--- a/ur/ur.go
+++ b/ur/ur.go
@@ -77,36 +77,24 @@ func (ur *ur) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (ur *ur) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ur.decimal) + len(ur.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ur.decimal) - 1; j >= 0; j-- {
- b = append(b, ur.decimal[j])
- }
-
+ b = append(b, ur.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(ur.group) - 1; j >= 0; j-- {
- b = append(b, ur.group[j])
- }
-
+ b = append(b, ur.group[0])
count = 1
} else {
count++
@@ -116,11 +104,16 @@ func (ur *ur) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(ur.minus) - 1; j >= 0; j-- {
+ b = append(b, ur.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ur_IN/ur_IN.go b/ur_IN/ur_IN.go
index f166b539..a99f2906 100644
--- a/ur_IN/ur_IN.go
+++ b/ur_IN/ur_IN.go
@@ -77,36 +77,24 @@ func (ur *ur_IN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ur *ur_IN) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ur.decimal) + len(ur.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ur.decimal) - 1; j >= 0; j-- {
- b = append(b, ur.decimal[j])
- }
-
+ b = append(b, ur.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(ur.group) - 1; j >= 0; j-- {
- b = append(b, ur.group[j])
- }
-
+ b = append(b, ur.group[0])
count = 1
} else {
count++
@@ -116,11 +104,16 @@ func (ur *ur_IN) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(ur.minus) - 1; j >= 0; j-- {
+ b = append(b, ur.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/ur_PK/ur_PK.go b/ur_PK/ur_PK.go
index 147805d2..7e9ac2ed 100644
--- a/ur_PK/ur_PK.go
+++ b/ur_PK/ur_PK.go
@@ -77,36 +77,24 @@ func (ur *ur_PK) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (ur *ur_PK) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(ur.decimal) + len(ur.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(ur.decimal) - 1; j >= 0; j-- {
- b = append(b, ur.decimal[j])
- }
-
+ b = append(b, ur.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(ur.group) - 1; j >= 0; j-- {
- b = append(b, ur.group[j])
- }
-
+ b = append(b, ur.group[0])
count = 1
} else {
count++
@@ -116,11 +104,16 @@ func (ur *ur_PK) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(ur.minus) - 1; j >= 0; j-- {
+ b = append(b, ur.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/uz/uz.go b/uz/uz.go
index 9efc05be..11575a4f 100644
--- a/uz/uz.go
+++ b/uz/uz.go
@@ -87,19 +87,15 @@ func (uz *uz) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (uz *uz) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(uz.decimal) + len(uz.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(uz.decimal) - 1; j >= 0; j-- {
b = append(b, uz.decimal[j])
}
@@ -110,9 +106,7 @@ func (uz *uz) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(uz.group) - 1; j >= 0; j-- {
b = append(b, uz.group[j])
}
@@ -126,11 +120,14 @@ func (uz *uz) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, uz.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/uz_Arab/uz_Arab.go b/uz_Arab/uz_Arab.go
index a5d05e6a..90abb9ee 100644
--- a/uz_Arab/uz_Arab.go
+++ b/uz_Arab/uz_Arab.go
@@ -87,19 +87,15 @@ func (uz *uz_Arab) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (uz *uz_Arab) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(uz.decimal) + len(uz.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(uz.decimal) - 1; j >= 0; j-- {
b = append(b, uz.decimal[j])
}
@@ -110,9 +106,7 @@ func (uz *uz_Arab) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(uz.group) - 1; j >= 0; j-- {
b = append(b, uz.group[j])
}
@@ -126,11 +120,14 @@ func (uz *uz_Arab) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, uz.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/uz_Arab_AF/uz_Arab_AF.go b/uz_Arab_AF/uz_Arab_AF.go
index 45e61cab..f9e1351e 100644
--- a/uz_Arab_AF/uz_Arab_AF.go
+++ b/uz_Arab_AF/uz_Arab_AF.go
@@ -87,19 +87,15 @@ func (uz *uz_Arab_AF) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2
// avoid allocations; otherwise just cast as string.
func (uz *uz_Arab_AF) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(uz.decimal) + len(uz.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(uz.decimal) - 1; j >= 0; j-- {
b = append(b, uz.decimal[j])
}
@@ -110,9 +106,7 @@ func (uz *uz_Arab_AF) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(uz.group) - 1; j >= 0; j-- {
b = append(b, uz.group[j])
}
@@ -126,11 +120,14 @@ func (uz *uz_Arab_AF) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, uz.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/uz_Cyrl/uz_Cyrl.go b/uz_Cyrl/uz_Cyrl.go
index 045dc408..4f22ce53 100644
--- a/uz_Cyrl/uz_Cyrl.go
+++ b/uz_Cyrl/uz_Cyrl.go
@@ -87,19 +87,15 @@ func (uz *uz_Cyrl) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (uz *uz_Cyrl) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(uz.decimal) + len(uz.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(uz.decimal) - 1; j >= 0; j-- {
b = append(b, uz.decimal[j])
}
@@ -110,9 +106,7 @@ func (uz *uz_Cyrl) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(uz.group) - 1; j >= 0; j-- {
b = append(b, uz.group[j])
}
@@ -126,11 +120,14 @@ func (uz *uz_Cyrl) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, uz.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/uz_Cyrl_UZ/uz_Cyrl_UZ.go b/uz_Cyrl_UZ/uz_Cyrl_UZ.go
index 989ded20..adf22699 100644
--- a/uz_Cyrl_UZ/uz_Cyrl_UZ.go
+++ b/uz_Cyrl_UZ/uz_Cyrl_UZ.go
@@ -87,19 +87,15 @@ func (uz *uz_Cyrl_UZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2
// avoid allocations; otherwise just cast as string.
func (uz *uz_Cyrl_UZ) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(uz.decimal) + len(uz.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(uz.decimal) - 1; j >= 0; j-- {
b = append(b, uz.decimal[j])
}
@@ -110,9 +106,7 @@ func (uz *uz_Cyrl_UZ) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(uz.group) - 1; j >= 0; j-- {
b = append(b, uz.group[j])
}
@@ -126,11 +120,14 @@ func (uz *uz_Cyrl_UZ) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, uz.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/uz_Latn/uz_Latn.go b/uz_Latn/uz_Latn.go
index 2181fd1c..e79250bb 100644
--- a/uz_Latn/uz_Latn.go
+++ b/uz_Latn/uz_Latn.go
@@ -87,19 +87,15 @@ func (uz *uz_Latn) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (uz *uz_Latn) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(uz.decimal) + len(uz.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(uz.decimal) - 1; j >= 0; j-- {
b = append(b, uz.decimal[j])
}
@@ -110,9 +106,7 @@ func (uz *uz_Latn) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(uz.group) - 1; j >= 0; j-- {
b = append(b, uz.group[j])
}
@@ -126,11 +120,14 @@ func (uz *uz_Latn) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, uz.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/uz_Latn_UZ/uz_Latn_UZ.go b/uz_Latn_UZ/uz_Latn_UZ.go
index 702b62b3..f1247509 100644
--- a/uz_Latn_UZ/uz_Latn_UZ.go
+++ b/uz_Latn_UZ/uz_Latn_UZ.go
@@ -87,19 +87,15 @@ func (uz *uz_Latn_UZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2
// avoid allocations; otherwise just cast as string.
func (uz *uz_Latn_UZ) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(uz.decimal) + len(uz.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
for j := len(uz.decimal) - 1; j >= 0; j-- {
b = append(b, uz.decimal[j])
}
@@ -110,9 +106,7 @@ func (uz *uz_Latn_UZ) FmtNumber(num float64, v uint64) []byte {
}
if inWhole {
-
if count == 3 {
-
for j := len(uz.group) - 1; j >= 0; j-- {
b = append(b, uz.group[j])
}
@@ -126,11 +120,14 @@ func (uz *uz_Latn_UZ) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, uz.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/vai/vai.go b/vai/vai.go
index 4178712a..4b6a9b01 100644
--- a/vai/vai.go
+++ b/vai/vai.go
@@ -1,6 +1,7 @@
package vai
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,36 +69,24 @@ func (vai *vai) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (vai *vai) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(vai.decimal) + len(vai.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(vai.decimal) - 1; j >= 0; j-- {
- b = append(b, vai.decimal[j])
- }
-
+ b = append(b, vai.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(vai.group) - 1; j >= 0; j-- {
- b = append(b, vai.group[j])
- }
-
+ b = append(b, vai.group[0])
count = 1
} else {
count++
@@ -107,11 +96,16 @@ func (vai *vai) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(vai.minus) - 1; j >= 0; j-- {
+ b = append(b, vai.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/vai_Latn/vai_Latn.go b/vai_Latn/vai_Latn.go
index 1ac1e755..9fcc92ea 100644
--- a/vai_Latn/vai_Latn.go
+++ b/vai_Latn/vai_Latn.go
@@ -1,6 +1,7 @@
package vai_Latn
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,36 +69,24 @@ func (vai *vai_Latn) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 u
// avoid allocations; otherwise just cast as string.
func (vai *vai_Latn) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(vai.decimal) + len(vai.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(vai.decimal) - 1; j >= 0; j-- {
- b = append(b, vai.decimal[j])
- }
-
+ b = append(b, vai.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(vai.group) - 1; j >= 0; j-- {
- b = append(b, vai.group[j])
- }
-
+ b = append(b, vai.group[0])
count = 1
} else {
count++
@@ -107,11 +96,16 @@ func (vai *vai_Latn) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(vai.minus) - 1; j >= 0; j-- {
+ b = append(b, vai.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/vai_Latn_LR/vai_Latn_LR.go b/vai_Latn_LR/vai_Latn_LR.go
index f95b2af2..b3a242f2 100644
--- a/vai_Latn_LR/vai_Latn_LR.go
+++ b/vai_Latn_LR/vai_Latn_LR.go
@@ -1,6 +1,7 @@
package vai_Latn_LR
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,36 +69,24 @@ func (vai *vai_Latn_LR) RangePluralRule(num1 float64, v1 uint64, num2 float64, v
// avoid allocations; otherwise just cast as string.
func (vai *vai_Latn_LR) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(vai.decimal) + len(vai.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(vai.decimal) - 1; j >= 0; j-- {
- b = append(b, vai.decimal[j])
- }
-
+ b = append(b, vai.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(vai.group) - 1; j >= 0; j-- {
- b = append(b, vai.group[j])
- }
-
+ b = append(b, vai.group[0])
count = 1
} else {
count++
@@ -107,11 +96,16 @@ func (vai *vai_Latn_LR) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(vai.minus) - 1; j >= 0; j-- {
+ b = append(b, vai.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/vai_Vaii/vai_Vaii.go b/vai_Vaii/vai_Vaii.go
index 0692ea99..5f7defda 100644
--- a/vai_Vaii/vai_Vaii.go
+++ b/vai_Vaii/vai_Vaii.go
@@ -1,6 +1,7 @@
package vai_Vaii
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,36 +69,24 @@ func (vai *vai_Vaii) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 u
// avoid allocations; otherwise just cast as string.
func (vai *vai_Vaii) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(vai.decimal) + len(vai.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(vai.decimal) - 1; j >= 0; j-- {
- b = append(b, vai.decimal[j])
- }
-
+ b = append(b, vai.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(vai.group) - 1; j >= 0; j-- {
- b = append(b, vai.group[j])
- }
-
+ b = append(b, vai.group[0])
count = 1
} else {
count++
@@ -107,11 +96,16 @@ func (vai *vai_Vaii) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(vai.minus) - 1; j >= 0; j-- {
+ b = append(b, vai.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/vai_Vaii_LR/vai_Vaii_LR.go b/vai_Vaii_LR/vai_Vaii_LR.go
index 0cdac4db..3f253a5d 100644
--- a/vai_Vaii_LR/vai_Vaii_LR.go
+++ b/vai_Vaii_LR/vai_Vaii_LR.go
@@ -1,6 +1,7 @@
package vai_Vaii_LR
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,36 +69,24 @@ func (vai *vai_Vaii_LR) RangePluralRule(num1 float64, v1 uint64, num2 float64, v
// avoid allocations; otherwise just cast as string.
func (vai *vai_Vaii_LR) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(vai.decimal) + len(vai.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(vai.decimal) - 1; j >= 0; j-- {
- b = append(b, vai.decimal[j])
- }
-
+ b = append(b, vai.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(vai.group) - 1; j >= 0; j-- {
- b = append(b, vai.group[j])
- }
-
+ b = append(b, vai.group[0])
count = 1
} else {
count++
@@ -107,11 +96,16 @@ func (vai *vai_Vaii_LR) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(vai.minus) - 1; j >= 0; j-- {
+ b = append(b, vai.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/vi/vi.go b/vi/vi.go
index f278ce68..12858623 100644
--- a/vi/vi.go
+++ b/vi/vi.go
@@ -76,36 +76,24 @@ func (vi *vi) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (vi *vi) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(vi.decimal) + len(vi.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(vi.decimal) - 1; j >= 0; j-- {
- b = append(b, vi.decimal[j])
- }
-
+ b = append(b, vi.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(vi.group) - 1; j >= 0; j-- {
- b = append(b, vi.group[j])
- }
-
+ b = append(b, vi.group[0])
count = 1
} else {
count++
@@ -115,11 +103,14 @@ func (vi *vi) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, vi.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/vi_VN/vi_VN.go b/vi_VN/vi_VN.go
index af9d0f7c..08fa28bd 100644
--- a/vi_VN/vi_VN.go
+++ b/vi_VN/vi_VN.go
@@ -76,36 +76,24 @@ func (vi *vi_VN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (vi *vi_VN) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(vi.decimal) + len(vi.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(vi.decimal) - 1; j >= 0; j-- {
- b = append(b, vi.decimal[j])
- }
-
+ b = append(b, vi.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(vi.group) - 1; j >= 0; j-- {
- b = append(b, vi.group[j])
- }
-
+ b = append(b, vi.group[0])
count = 1
} else {
count++
@@ -115,11 +103,14 @@ func (vi *vi_VN) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, vi.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/vo/vo.go b/vo/vo.go
index 035f82e8..7d210267 100644
--- a/vo/vo.go
+++ b/vo/vo.go
@@ -76,8 +76,6 @@ func (vo *vo) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (vo *vo) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/vo_001/vo_001.go b/vo_001/vo_001.go
index 5b199501..584c7cc6 100644
--- a/vo_001/vo_001.go
+++ b/vo_001/vo_001.go
@@ -76,8 +76,6 @@ func (vo *vo_001) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint
// avoid allocations; otherwise just cast as string.
func (vo *vo_001) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/vun/vun.go b/vun/vun.go
index 08566882..716404a5 100644
--- a/vun/vun.go
+++ b/vun/vun.go
@@ -76,8 +76,6 @@ func (vun *vun) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (vun *vun) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/vun_TZ/vun_TZ.go b/vun_TZ/vun_TZ.go
index 23cd2aa7..27631df3 100644
--- a/vun_TZ/vun_TZ.go
+++ b/vun_TZ/vun_TZ.go
@@ -76,8 +76,6 @@ func (vun *vun_TZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (vun *vun_TZ) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/wae/wae.go b/wae/wae.go
index 47511e3f..69f037fb 100644
--- a/wae/wae.go
+++ b/wae/wae.go
@@ -76,8 +76,6 @@ func (wae *wae) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (wae *wae) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/wae_CH/wae_CH.go b/wae_CH/wae_CH.go
index 5373411e..116a1162 100644
--- a/wae_CH/wae_CH.go
+++ b/wae_CH/wae_CH.go
@@ -76,8 +76,6 @@ func (wae *wae_CH) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (wae *wae_CH) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/xog/xog.go b/xog/xog.go
index 46211a34..02ebbd94 100644
--- a/xog/xog.go
+++ b/xog/xog.go
@@ -76,8 +76,6 @@ func (xog *xog) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (xog *xog) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/xog_UG/xog_UG.go b/xog_UG/xog_UG.go
index 67148411..23291776 100644
--- a/xog_UG/xog_UG.go
+++ b/xog_UG/xog_UG.go
@@ -76,8 +76,6 @@ func (xog *xog_UG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (xog *xog_UG) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/yav/yav.go b/yav/yav.go
index 46057742..ee0e3fc9 100644
--- a/yav/yav.go
+++ b/yav/yav.go
@@ -1,6 +1,7 @@
package yav
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,32 +69,23 @@ func (yav *yav) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (yav *yav) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(yav.decimal) + len(yav.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(yav.decimal) - 1; j >= 0; j-- {
- b = append(b, yav.decimal[j])
- }
-
+ b = append(b, yav.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(yav.group) - 1; j >= 0; j-- {
b = append(b, yav.group[j])
}
@@ -107,11 +99,16 @@ func (yav *yav) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(yav.minus) - 1; j >= 0; j-- {
+ b = append(b, yav.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/yav_CM/yav_CM.go b/yav_CM/yav_CM.go
index 601121f8..c02e898c 100644
--- a/yav_CM/yav_CM.go
+++ b/yav_CM/yav_CM.go
@@ -1,6 +1,7 @@
package yav_CM
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,32 +69,23 @@ func (yav *yav_CM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (yav *yav_CM) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(yav.decimal) + len(yav.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(yav.decimal) - 1; j >= 0; j-- {
- b = append(b, yav.decimal[j])
- }
-
+ b = append(b, yav.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(yav.group) - 1; j >= 0; j-- {
b = append(b, yav.group[j])
}
@@ -107,11 +99,16 @@ func (yav *yav_CM) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(yav.minus) - 1; j >= 0; j-- {
+ b = append(b, yav.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/yi/yi.go b/yi/yi.go
index 7738e58f..7c5dafea 100644
--- a/yi/yi.go
+++ b/yi/yi.go
@@ -77,8 +77,6 @@ func (yi *yi) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (yi *yi) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/yi_001/yi_001.go b/yi_001/yi_001.go
index c0f36a08..d9994566 100644
--- a/yi_001/yi_001.go
+++ b/yi_001/yi_001.go
@@ -77,8 +77,6 @@ func (yi *yi_001) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint
// avoid allocations; otherwise just cast as string.
func (yi *yi_001) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/yo/yo.go b/yo/yo.go
index 444bc7ff..9f909305 100644
--- a/yo/yo.go
+++ b/yo/yo.go
@@ -1,6 +1,7 @@
package yo
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,8 +69,6 @@ func (yo *yo) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (yo *yo) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/yo_BJ/yo_BJ.go b/yo_BJ/yo_BJ.go
index fe34d500..07e05ff9 100644
--- a/yo_BJ/yo_BJ.go
+++ b/yo_BJ/yo_BJ.go
@@ -1,6 +1,7 @@
package yo_BJ
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,8 +69,6 @@ func (yo *yo_BJ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (yo *yo_BJ) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/yo_NG/yo_NG.go b/yo_NG/yo_NG.go
index eab925a9..ea766bfa 100644
--- a/yo_NG/yo_NG.go
+++ b/yo_NG/yo_NG.go
@@ -1,6 +1,7 @@
package yo_NG
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,8 +69,6 @@ func (yo *yo_NG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (yo *yo_NG) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/yue/yue.go b/yue/yue.go
index 13adf97f..f3f19d5b 100644
--- a/yue/yue.go
+++ b/yue/yue.go
@@ -1,6 +1,7 @@
package yue
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,36 +69,24 @@ func (yue *yue) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (yue *yue) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(yue.decimal) + len(yue.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(yue.decimal) - 1; j >= 0; j-- {
- b = append(b, yue.decimal[j])
- }
-
+ b = append(b, yue.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(yue.group) - 1; j >= 0; j-- {
- b = append(b, yue.group[j])
- }
-
+ b = append(b, yue.group[0])
count = 1
} else {
count++
@@ -107,11 +96,14 @@ func (yue *yue) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, yue.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/yue_HK/yue_HK.go b/yue_HK/yue_HK.go
index 3b44fea0..281c89ca 100644
--- a/yue_HK/yue_HK.go
+++ b/yue_HK/yue_HK.go
@@ -1,6 +1,7 @@
package yue_HK
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,36 +69,24 @@ func (yue *yue_HK) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (yue *yue_HK) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(yue.decimal) + len(yue.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(yue.decimal) - 1; j >= 0; j-- {
- b = append(b, yue.decimal[j])
- }
-
+ b = append(b, yue.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(yue.group) - 1; j >= 0; j-- {
- b = append(b, yue.group[j])
- }
-
+ b = append(b, yue.group[0])
count = 1
} else {
count++
@@ -107,11 +96,14 @@ func (yue *yue_HK) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, yue.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/zgh/zgh.go b/zgh/zgh.go
index 3558901f..a5874ff2 100644
--- a/zgh/zgh.go
+++ b/zgh/zgh.go
@@ -1,6 +1,7 @@
package zgh
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,8 +69,6 @@ func (zgh *zgh) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64
// avoid allocations; otherwise just cast as string.
func (zgh *zgh) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/zgh_MA/zgh_MA.go b/zgh_MA/zgh_MA.go
index dd7a9c21..d19d9d3a 100644
--- a/zgh_MA/zgh_MA.go
+++ b/zgh_MA/zgh_MA.go
@@ -1,6 +1,7 @@
package zgh_MA
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,8 +69,6 @@ func (zgh *zgh_MA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (zgh *zgh_MA) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
-
}
diff --git a/zh/zh.go b/zh/zh.go
index 293bebf4..20b2f0ba 100644
--- a/zh/zh.go
+++ b/zh/zh.go
@@ -1,6 +1,7 @@
package zh
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,36 +69,24 @@ func (zh *zh) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (zh *zh) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(zh.decimal) + len(zh.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(zh.decimal) - 1; j >= 0; j-- {
- b = append(b, zh.decimal[j])
- }
-
+ b = append(b, zh.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(zh.group) - 1; j >= 0; j-- {
- b = append(b, zh.group[j])
- }
-
+ b = append(b, zh.group[0])
count = 1
} else {
count++
@@ -107,11 +96,14 @@ func (zh *zh) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, zh.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/zh_Hans/zh_Hans.go b/zh_Hans/zh_Hans.go
index 80052696..cd97fa2c 100644
--- a/zh_Hans/zh_Hans.go
+++ b/zh_Hans/zh_Hans.go
@@ -1,6 +1,7 @@
package zh_Hans
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,36 +69,24 @@ func (zh *zh_Hans) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (zh *zh_Hans) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(zh.decimal) + len(zh.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(zh.decimal) - 1; j >= 0; j-- {
- b = append(b, zh.decimal[j])
- }
-
+ b = append(b, zh.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(zh.group) - 1; j >= 0; j-- {
- b = append(b, zh.group[j])
- }
-
+ b = append(b, zh.group[0])
count = 1
} else {
count++
@@ -107,11 +96,14 @@ func (zh *zh_Hans) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, zh.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/zh_Hans_CN/zh_Hans_CN.go b/zh_Hans_CN/zh_Hans_CN.go
index fdca106f..d6e9a7af 100644
--- a/zh_Hans_CN/zh_Hans_CN.go
+++ b/zh_Hans_CN/zh_Hans_CN.go
@@ -1,6 +1,7 @@
package zh_Hans_CN
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,36 +69,24 @@ func (zh *zh_Hans_CN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2
// avoid allocations; otherwise just cast as string.
func (zh *zh_Hans_CN) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(zh.decimal) + len(zh.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(zh.decimal) - 1; j >= 0; j-- {
- b = append(b, zh.decimal[j])
- }
-
+ b = append(b, zh.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(zh.group) - 1; j >= 0; j-- {
- b = append(b, zh.group[j])
- }
-
+ b = append(b, zh.group[0])
count = 1
} else {
count++
@@ -107,11 +96,14 @@ func (zh *zh_Hans_CN) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, zh.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/zh_Hans_HK/zh_Hans_HK.go b/zh_Hans_HK/zh_Hans_HK.go
index d3c13edb..9ef1405b 100644
--- a/zh_Hans_HK/zh_Hans_HK.go
+++ b/zh_Hans_HK/zh_Hans_HK.go
@@ -1,6 +1,7 @@
package zh_Hans_HK
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,36 +69,24 @@ func (zh *zh_Hans_HK) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2
// avoid allocations; otherwise just cast as string.
func (zh *zh_Hans_HK) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(zh.decimal) + len(zh.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(zh.decimal) - 1; j >= 0; j-- {
- b = append(b, zh.decimal[j])
- }
-
+ b = append(b, zh.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(zh.group) - 1; j >= 0; j-- {
- b = append(b, zh.group[j])
- }
-
+ b = append(b, zh.group[0])
count = 1
} else {
count++
@@ -107,11 +96,14 @@ func (zh *zh_Hans_HK) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, zh.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/zh_Hans_MO/zh_Hans_MO.go b/zh_Hans_MO/zh_Hans_MO.go
index bc433904..26abbd2c 100644
--- a/zh_Hans_MO/zh_Hans_MO.go
+++ b/zh_Hans_MO/zh_Hans_MO.go
@@ -1,6 +1,7 @@
package zh_Hans_MO
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,36 +69,24 @@ func (zh *zh_Hans_MO) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2
// avoid allocations; otherwise just cast as string.
func (zh *zh_Hans_MO) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(zh.decimal) + len(zh.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(zh.decimal) - 1; j >= 0; j-- {
- b = append(b, zh.decimal[j])
- }
-
+ b = append(b, zh.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(zh.group) - 1; j >= 0; j-- {
- b = append(b, zh.group[j])
- }
-
+ b = append(b, zh.group[0])
count = 1
} else {
count++
@@ -107,11 +96,14 @@ func (zh *zh_Hans_MO) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, zh.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/zh_Hans_SG/zh_Hans_SG.go b/zh_Hans_SG/zh_Hans_SG.go
index 8526f6b1..d9dedcab 100644
--- a/zh_Hans_SG/zh_Hans_SG.go
+++ b/zh_Hans_SG/zh_Hans_SG.go
@@ -1,6 +1,7 @@
package zh_Hans_SG
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,36 +69,24 @@ func (zh *zh_Hans_SG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2
// avoid allocations; otherwise just cast as string.
func (zh *zh_Hans_SG) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(zh.decimal) + len(zh.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(zh.decimal) - 1; j >= 0; j-- {
- b = append(b, zh.decimal[j])
- }
-
+ b = append(b, zh.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(zh.group) - 1; j >= 0; j-- {
- b = append(b, zh.group[j])
- }
-
+ b = append(b, zh.group[0])
count = 1
} else {
count++
@@ -107,11 +96,14 @@ func (zh *zh_Hans_SG) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, zh.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/zh_Hant/zh_Hant.go b/zh_Hant/zh_Hant.go
index 4d39dcb5..358f1052 100644
--- a/zh_Hant/zh_Hant.go
+++ b/zh_Hant/zh_Hant.go
@@ -1,6 +1,7 @@
package zh_Hant
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,36 +69,24 @@ func (zh *zh_Hant) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uin
// avoid allocations; otherwise just cast as string.
func (zh *zh_Hant) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(zh.decimal) + len(zh.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(zh.decimal) - 1; j >= 0; j-- {
- b = append(b, zh.decimal[j])
- }
-
+ b = append(b, zh.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(zh.group) - 1; j >= 0; j-- {
- b = append(b, zh.group[j])
- }
-
+ b = append(b, zh.group[0])
count = 1
} else {
count++
@@ -107,11 +96,14 @@ func (zh *zh_Hant) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, zh.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/zh_Hant_HK/zh_Hant_HK.go b/zh_Hant_HK/zh_Hant_HK.go
index f391f1e2..68f08932 100644
--- a/zh_Hant_HK/zh_Hant_HK.go
+++ b/zh_Hant_HK/zh_Hant_HK.go
@@ -1,6 +1,7 @@
package zh_Hant_HK
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,36 +69,24 @@ func (zh *zh_Hant_HK) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2
// avoid allocations; otherwise just cast as string.
func (zh *zh_Hant_HK) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(zh.decimal) + len(zh.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(zh.decimal) - 1; j >= 0; j-- {
- b = append(b, zh.decimal[j])
- }
-
+ b = append(b, zh.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(zh.group) - 1; j >= 0; j-- {
- b = append(b, zh.group[j])
- }
-
+ b = append(b, zh.group[0])
count = 1
} else {
count++
@@ -107,11 +96,14 @@ func (zh *zh_Hant_HK) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, zh.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/zh_Hant_MO/zh_Hant_MO.go b/zh_Hant_MO/zh_Hant_MO.go
index 05e5dc22..f1b302cf 100644
--- a/zh_Hant_MO/zh_Hant_MO.go
+++ b/zh_Hant_MO/zh_Hant_MO.go
@@ -1,6 +1,7 @@
package zh_Hant_MO
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,36 +69,24 @@ func (zh *zh_Hant_MO) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2
// avoid allocations; otherwise just cast as string.
func (zh *zh_Hant_MO) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(zh.decimal) + len(zh.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(zh.decimal) - 1; j >= 0; j-- {
- b = append(b, zh.decimal[j])
- }
-
+ b = append(b, zh.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(zh.group) - 1; j >= 0; j-- {
- b = append(b, zh.group[j])
- }
-
+ b = append(b, zh.group[0])
count = 1
} else {
count++
@@ -107,11 +96,14 @@ func (zh *zh_Hant_MO) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, zh.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/zh_Hant_TW/zh_Hant_TW.go b/zh_Hant_TW/zh_Hant_TW.go
index 60e801ce..88b148c8 100644
--- a/zh_Hant_TW/zh_Hant_TW.go
+++ b/zh_Hant_TW/zh_Hant_TW.go
@@ -1,6 +1,7 @@
package zh_Hant_TW
import (
+ "math"
"strconv"
"github.com/go-playground/locales"
@@ -68,36 +69,24 @@ func (zh *zh_Hant_TW) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2
// avoid allocations; otherwise just cast as string.
func (zh *zh_Hant_TW) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(zh.decimal) + len(zh.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(zh.decimal) - 1; j >= 0; j-- {
- b = append(b, zh.decimal[j])
- }
-
+ b = append(b, zh.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(zh.group) - 1; j >= 0; j-- {
- b = append(b, zh.group[j])
- }
-
+ b = append(b, zh.group[0])
count = 1
} else {
count++
@@ -107,11 +96,14 @@ func (zh *zh_Hant_TW) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, zh.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/zu/zu.go b/zu/zu.go
index 81a96089..9b9f9d9d 100644
--- a/zu/zu.go
+++ b/zu/zu.go
@@ -88,36 +88,24 @@ func (zu *zu) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (zu *zu) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(zu.decimal) + len(zu.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(zu.decimal) - 1; j >= 0; j-- {
- b = append(b, zu.decimal[j])
- }
-
+ b = append(b, zu.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(zu.group) - 1; j >= 0; j-- {
- b = append(b, zu.group[j])
- }
-
+ b = append(b, zu.group[0])
count = 1
} else {
count++
@@ -127,11 +115,14 @@ func (zu *zu) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, zu.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}
diff --git a/zu_ZA/zu_ZA.go b/zu_ZA/zu_ZA.go
index ab476958..f71a0fa2 100644
--- a/zu_ZA/zu_ZA.go
+++ b/zu_ZA/zu_ZA.go
@@ -88,36 +88,24 @@ func (zu *zu_ZA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (zu *zu_ZA) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(zu.decimal) + len(zu.group)*len(s[:len(s)-int(v)-1])/3
-
count := 0
inWhole := v == 0
-
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(zu.decimal) - 1; j >= 0; j-- {
- b = append(b, zu.decimal[j])
- }
-
+ b = append(b, zu.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
- for j := len(zu.group) - 1; j >= 0; j-- {
- b = append(b, zu.group[j])
- }
-
+ b = append(b, zu.group[0])
count = 1
} else {
count++
@@ -127,11 +115,14 @@ func (zu *zu_ZA) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, zu.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}