@@ -205,44 +205,36 @@ def intword(value: NumberOrString, format: str = "%.1f") -> str:
205
205
except (TypeError , ValueError ):
206
206
return str (value )
207
207
208
- is_negative = value < 0
209
-
210
- if is_negative :
208
+ if value < 0 :
211
209
value *= - 1
210
+ negative_prefix = "-"
211
+ else :
212
+ negative_prefix = ""
212
213
213
214
if value < powers [0 ]:
214
- return "-" + str ( value ) if is_negative else str (value )
215
+ return negative_prefix + str (value )
215
216
for ordinal , power in enumerate (powers [1 :], 1 ):
216
217
if value < power :
217
218
chopped = value / float (powers [ordinal - 1 ])
218
219
if float (format % chopped ) == float (10 ** 3 ):
219
220
chopped = value / float (powers [ordinal ])
220
221
singular , plural = human_powers [ordinal ]
221
- if is_negative :
222
- return (
223
- "-"
224
- + " " .join (
225
- [format , _ngettext (singular , plural , math .ceil (chopped ))]
226
- )
227
- ) % chopped
228
-
229
222
return (
230
- " " .join ([format , _ngettext (singular , plural , math .ceil (chopped ))])
223
+ negative_prefix
224
+ + " " .join (
225
+ [format , _ngettext (singular , plural , math .ceil (chopped ))]
226
+ )
231
227
) % chopped
232
228
else :
233
229
singular , plural = human_powers [ordinal - 1 ]
234
- if is_negative :
235
- return (
236
- "-"
237
- + " " .join (
238
- [format , _ngettext (singular , plural , math .ceil (chopped ))]
239
- )
240
- ) % chopped
241
230
return (
242
- " " .join ([format , _ngettext (singular , plural , math .ceil (chopped ))])
231
+ negative_prefix
232
+ + " " .join (
233
+ [format , _ngettext (singular , plural , math .ceil (chopped ))]
234
+ )
243
235
) % chopped
244
236
245
- return "-" + str ( value ) if is_negative else str (value )
237
+ return negative_prefix + str (value )
246
238
247
239
248
240
def apnumber (value : NumberOrString ) -> str :
0 commit comments