number_separators.gd 607 B

1234567891011121314151617181920212223242526
  1. func test():
  2. # `_` can be used as a separator for numbers in GDScript.
  3. # It can be placed anywhere in the number, except at the beginning.
  4. print(1_23)
  5. print(12_3)
  6. print(1_2_3)
  7. print(123_) # Trailing number separators are OK.
  8. print(123_456)
  9. print(123_45_6_)
  10. print("---")
  11. print(0x1234_00ff)
  12. print(0x1234_00_f_f_)
  13. print(0b1001_0101)
  14. print(0b1001_01_0_1_)
  15. print("---")
  16. print(-1_234.456_7)
  17. print(-1_23_4_.4_56_7_)
  18. print(-1_234.)
  19. print(-1_23_4_.)
  20. print(.456_7)
  21. print(.4_56_7_)
  22. print("---")
  23. print(-1_234.5e000_3)
  24. print(-1_23_4_.5e0_00_3_)
  25. print(-1_234.5e+000_3)
  26. print(-1_23_4_.5e+0_00_3_)