csharplang icon indicating copy to clipboard operation
csharplang copied to clipboard

Champion "Binary Literals" and "Digit Separators" (C# 7.0)

Open gafter opened this issue 8 years ago • 4 comments

See also

  • https://github.com/dotnet/roslyn/issues/215
  • https://github.com/dotnet/roslyn/issues/216

gafter avatar Feb 10 '17 22:02 gafter

This is a "proposal issue" because we need to add a proposal/spec to the repo.

gafter avatar Feb 10 '17 22:02 gafter

Is there any particular reason why digit separators are allowed in integer digits, but not in fraction digits? For example:

> 1_2;             // "Works" (weirdly), 122
> 1_2.34;       // "Works" (wierdly), 122.34
> 122.3_4;     // Fails, (1,6): error CS1525: Unexpected symbol `_4'

System Information (running Mono on Fedora 30):

$ mono --version
Mono JIT compiler version 6.8.0.96 (tarball Wed Jan 15 09:00:57 UTC 2020)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
	TLS:           __thread
	SIGSEGV:       altstack
	Notifications: epoll
	Architecture:  amd64
	Disabled:      none
	Misc:          softdebug 
	Interpreter:   yes
	LLVM:          yes(610)
	Suspend:       hybrid
	GC:            sgen (concurrent by default)

Command To Start Interpreter:

csharp -langversion:Experimental

Alexhuszagh avatar Jan 15 '20 23:01 Alexhuszagh

Is there any particular reason why digit separators are allowed in integer digits, but not in fraction digits?

It is allowed.

Fails, (1,6): error CS1525: Unexpected symbol `_4' System Information (running Mono on Fedora 30):

Sounds like a mono problem. Maybe report this to them?

CyrusNajmabadi avatar Jan 15 '20 23:01 CyrusNajmabadi

Specification in progress at https://github.com/dotnet/csharpstandard/pull/548.

gafter avatar May 13 '22 23:05 gafter